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
698 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 108

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 108

Expert Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 …

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now