Real Estate Forums
| MLS listings and IDX Solutions Discuss implementation of MLS / IDX solutions, MLS providers and how to improve conversion using the multiple listings service available in your area. |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
I think it would probably be easier to upload the images directly into its own database. Is this realistic to do?
|
|
|||
|
I work with uploaded images often. I suggest to keep your images in their own folder and the filenames in the database, or even better, dynamically create folder names keyed to a unique value (like the MLS ID). That way, you can programatically check if the folder exists, and if so display all images for that property without a database lookup!
http://www.donaldlee.net |
|
|||
|
As i know, the information you store in the database it's stored in files as well. So if you have a file on your hard, you have it in the database, the content of that file is in both cases on hard somewhere. If you keep it in the database, most chances are that some extra info about the row with the file is added. I'd say it's better to keep the file on hard and maybe the filename in the database
|
|
|||
|
You can store the images as a BLOB in your database however there's several reasons not to.
It'll make your database huge If you convert to a different database type your BLOB might not be compatible Not storing it in the database gives you access to these images in different ways such as FTP There will be a much faster load time on your website if you don't store in the database (Don't have to call a SQL query for the images, then stream it to the user, etc..). |
|
|||
|
Ok, I thought I had everything figured out, but my residential image script times out when it comes to putting the file names into a data base. Heres how it works ..
- Delete old info table and read in new mls info to res_info_database table - Delete old image table and create new empty res_image_database table - Copy new image .zip files from MLS server to my server. - Unzip the .zip files - Make an array of all file names in the image folder. (old and new) - Explode the file name to extract the mls number the file belongs to. - IF the mls number is not equal to a res_info_table entry then delete the file - IF the mls number is equal to an info database entry then insert/update image file name for the proper image# on the mls# row in the res_image_table) example: image data schema .. mlsnumber int(10) .. image01 char(40) .. image02 (char40) .. image03 (char40) .. image04 (char40) .. ect .. The problem is my script times out when inserting the image names into the database. The MLS number is a PRIMARY INDEX and I set the mysql SELECT statement to only scan for the mls number and a LIMIT = 1, but it still times out. Is there an optimization I am missing? Am I going about it all wrong by trying to scan the entire image folder each update? Last edited by FProps : 04-06-2008 at 08:41 PM. |
|
|||
|
Can you post your query
|
|
|||
|
Heres what the code looks like, I changed variables and made it something like seudo code ..
$mydir = >>image_directory<< while (>>next_file<< != null) // read down list of image files { $next_file = explode('_', $file); // break image name into parts $result = mysql_query("SELECT MLSnumber FROM info_list WHERE MLSnumber = '$nextfile_mlsnumber' LIMIT 1"); // see if current image mlsnumber is still in the info database. if (mysql_num_rows($result) == 0) // if not in database, delete { delete($next_file); } else // if it is in database, add filename to image_table { $result = mysql_query("SELECT mlsnumber FROM res_images WHERE mlsnumber = '$nextfile_mlsnumber' LIMIT 1"); if (mysql_num_rows($result) == 0) // if not currently in image_database, add new row { mysql_query("INSERT INTO ctmls_res_images (mlsnum) VALUES ('$filearray[0]')"); } // insert file_name into image column for given mlsnumber row .. switch (nextfile_imagenumber) { case 101 : mysql_query("UPDATE res_images SET image01 = '$nextfile' WHERE mlsnumber = '$next_file'"); break; case 201 : mysql_query("UPDATE res_images SET image02 = '$nextfile' WHERE mlsnumber = '$next_file'"); break; ect ... } } } |
|
|||
|
How many times does that loop run generally?
|
|
|||
|
The while loop is for every image in the folder.. so about 1450 times :X
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming / Database Technical | RonnieG | Metrolist Development | 4 | 11-13-2007 10:00 AM |
| Problems uploading pictures. | Morristown | Blogs | 5 | 09-29-2007 08:16 PM |
| Vector Images | Agnafl | Webmasters Toolkit | 4 | 07-16-2007 07:48 PM |
| Image(s) Not Found Red X | Calgary Agent | REW CMS 1 Questions | 1 | 05-07-2007 02:04 PM |
| Uploading Images | Memphis | REW CMS 1 Questions | 7 | 04-14-2006 04:46 PM |