Re: Question re large objects

Поиск
Список
Период
Сортировка
От Mitch Vincent
Тема Re: Question re large objects
Дата
Msg-id 00f901c0596f$c5903c60$0200000a@windows
обсуждение исходный текст
Ответ на RE: Question re large objects  ("Justin Long" <justinlong@strategicnetwork.org>)
Список pgsql-php
Sure, you could break the image up into pieces -- you just need to be sure
you put every byte right back where you got it in the whole image.. All in
all I think storing images for display on web pages in any database is much
more trouble than it's worth...

A flat file system with a naming scheme should work rather well (I use
something like this in several applications to deal with MS-Word documents
and the like).. You could even store the image as a flat-file and stick the
name and path in the directory, that way you could grab the link right out
of the database and display it.. This approach requires you have a directory
for each user so that they can have files named the same thing, that or you
can put some ID in the file name to identify it's owner (you'll have
directories for each user anyway I would assume).

Good luck!

-Mitch

----- Original Message -----
From: "Justin Long" <justinlong@strategicnetwork.org>
To: "Pgsql-Php" <pgsql-php@postgresql.org>
Sent: Tuesday, November 28, 2000 9:48 AM
Subject: RE: [PHP] Question re large objects


> The tuple limit is the reason why we created a function for writing large
> text files to a database. Here's the function we use:
>
> function inject($id, $text) {
> // this function splits the article, $text, into 4k chunks and stores it.
> global $db;
> $rs = db_exec("SELECT * FROM article WHERE textid LIKE '$id-%'"); // check
> to see if the text exists
> if ($rs) {
> db_exec("DELETE FROM article WHERE textid LIKE '$id-%'"); // delete old
> text if it does
> }
> $row=1;
> $string="";
> while ($text != "") {
> if (strlen($text) <= 4096) {
> $string = $text;
> $text = "";
> } else {
> $x = 4096;
> while (substr($text,$x,1) != "\n" && $x > 0) { $x = $x - 1; }
> if ($x==0) {
> $x = 4096;
> while (substr($text,$x,1) != " " && $x > 0) { $x = $x - 1; }
> }
> $string = substr($text,0,$x);
> $text = substr($text,$x+1);
> }
> $string = trim($string);
> if ($string!="") {
> $blockid = $id . "-" . substr("00".$row,-2);
> $len = strlen($id);
> $kbid = str_replace("KB","",$id);
> if (strpos($kbid,":")) { $kbid = substr($kbid,0,strpos($kbid,":")); }
> if (!$kbid) { $string = addslashes($string); }
> if ($len > strlen($kbid)) {
> $sql = "INSERT INTO article (kbid,textid,article) VALUES
> ('$kbid','$blockid','$string')";
> db_exec($sql);
> } else {
> db_exec("INSERT INTO article (textid,article) VALUES
> ('$blockid','$string')");
> }
> }
> $row++;
> }
> }
>
> function retrieve($id) {
> // this function retrieves and concatenates the files.
> $rs = db_exec("SELECT * from article WHERE textid LIKE '$id-%' ORDER BY
> textid"); // check to see if text exists
> if ($rs) {
> $row=0;
> $string="";
> while ($row < pg_numrows($rs)) {
> $rec = pg_fetch_object($rs,$row);
> $string = $string . $rec->article;
> $row++;
> }
> } else {
> $string="";
> }
> return($string);
> }
>
>
> It's likely, with a little bit of tweaking, that these functions could be
> used to store image files?
>
> Justin
>
>


В списке pgsql-php по дате отправления:

Предыдущее
От: "Justin Long"
Дата:
Сообщение: RE: Question re large objects
Следующее
От: Stephen van Egmond
Дата:
Сообщение: Re: Question re large objects