RE: [PHP-DB] Q & A (Images in a database)

From: Date: Mon, 09 Oct 2000 14:37:18 +0000
Subject: RE: [PHP-DB] Q & A (Images in a database)
Groups: php.db 
Request: Send a blank email to php-db+get-3436@lists.php.net to get a copy of this message
This seems to pop up a lot on this list. I don't know if there is a perfect answer, it tends to be more of personal preference. Storing the image in the database causes, a very large database, and a separate call to load the image. The final output of the HTML code has to execute a php script to get the image. Like this (HTML code) <image src="getimage.php?id=27">. First you generate the page (index.php) when it's loaded, then when the page is processed (by the client) they have to make another call to get the image (with getimage.php). The client has to call getimage.php each time it needs an image. Because of this I've leaned towards storing the path to the image in the database (and put the images in a directory on the server). This keeps the image table small (and hopefully faster). And the HTML code that is processed on the client doesn't make a second PHP call to get the image (It still has to go back to the server to get the image file, but it doesn't have to execute PHP code and pull it out of the SQL databse. In conclusion, I beleive (but hey, who the hell am I anyway) that it's simpler, faster, and takes less resources to call images from a directory in the server. You're not overworking PHP, or SQL, just the HTTP server. I don't know anything about the actual impact on system load, it just seems to make sense to me (for some reason). Hope this helps. Mario -----Original Message----- From: Bart A. Verbeek [mailto:b.a.verbeek@wanadoo.nl] Sent: Monday, October 09, 2000 10:16 AM To: php-db@lists.php.net Subject: [PHP-DB] Q & A Hello, Hope all you people can help me again.... I want to create a database with pictures (and descriptions). Is it better to store the picture in the DB itself or is it better to store the pictures in a folder (say 'pictures') and store the path (to picture) in the DB with the description. Wich one is faster? In DB-stored pictures or php/MySQL-generated file-paths converted to HTML?? Hope you all have an answer? Regards Bart

« previous php.db (#3436) next »