0

I have a PHP script that takes an image from an Oracle database and saves it into a MySQL database.

It worked fine until I upgraded to PHP 5.3.3 from PHP 5.1.6. The part that queries the Oracle database no longer works. It can query all fields apart from the image field. I believe it is a BLOB.

For instance, the below code outputs Resource id #6

$sql2 = "SELECT CREATIVE FROM creative WHERE id = 10314612";
    foreach($oci->query($sql2) as $row2) {
        echo $row2['CREATIVE']; 
    }
5
  • From PHP doc: "By default, LOB columns are returned as LOB descriptors." Try something like $rows["CREATIVE"]->load(). Commented Mar 18, 2014 at 11:36
  • Thanks for the reply, but that gives me: Fatal error: Call to a member function load() on a non-object Commented Mar 18, 2014 at 11:51
  • What does var_dump($row2['CREATIVE']) say? Commented Mar 18, 2014 at 11:58
  • resource(6) of type (stream) Commented Mar 18, 2014 at 12:02
  • How is your OCI wrapper implemented? What does current give in your $oci->query? Commented Mar 19, 2014 at 2:56

1 Answer 1

2

I've finally fixed it.

The code now looks like this:

$stmt = $dbcon->prepare( 'SELECT CREATIVE FROM creative WHERE id = 10314612'); 
$stmt->execute(); 
$res = $stmt->fetchAll( PDO::FETCH_ASSOC ); 

for( $i=0; $i<count($res); $i++ ){ 
  $data = stream_get_contents( $res[$i]['CREATIVE'] ); 
} 

Thanks for your help Passerby.

I don't understand why it works. I just copied the above from one of the examples on php.net

If anyone knows why, it would be great if they could post it here :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.