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
707 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

696 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