Solved

How can I save an image from SQL Server 2008 R2 database image field to web server drive using PHP

Posted on 2013-06-07
2
705 Views
Last Modified: 2013-06-10
Greetings!

I have an application that syncs data from a SQL Server 2008 R2 database to a PHP driven web application.

The database has product images stored in datatype image fields and I need to save the  image to a file on the web server drive and then insert a link into the mySQL table for the application.

This is on a Centos web server using PHP with mssql extensions for php.

I would really appreciate any direction on accomplishing this.

Lynn
0
Comment
Question by:lthames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39230417
Without any test data I can't answer this completely, but the general flow would go something like this.

Add a column to the product images table that indicates "isProcessed."  You want this because you will not want a query that does a SELECT * without LIMIT.  That will give you too much data.

SELECT the image information from the product images table with TOP(5) or some similar limit and a WHERE clause that looks for a negative indicator in the "isProcessed" column.  Write the image information into the server file system (use your own methods of determining the image file name).  When the write is complete, INSERT the file name URL into the MySQL data base.  Then UPDATE the product images table to show that the row has been processed.

You can rerun this query structure over and over, until all of the MSSQL data base rows show "isProcessed."
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39235232
Thanks for the points and best of luck with it, ~Ray
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP SMTP authentication 6 24
how to use jquery variable in mysql query 20 31
Database Mail Profiles 1 18
php hashing methods 3 10
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question