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
703 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
  • 2
2 Comments
 
LVL 109

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 109

Expert Comment

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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

789 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