ZendAMF ByteArray

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ZendAMF ByteArray

yavstr
I'm passing an AS3 Image class over to PHP.

The image class contains the following information
byteArray
description

in my save method I'm pulling the bytearray out and saving that into my DB in a blob like so:
public function SaveImage (Image $im)
{
        $ba = new Zend_Amf_Value_ByteArray ( $im->bArray );
        $data = mysql_real_escape_string ( $ba->getData () );
               
        $query = "INSERT INTO  image ( byteArray ) VALUES ( '".$data."' );";
        $result = mysql_query($query);
        $error = mysql_error();
               
        if($error)
                return "Error: " . $error;
        else
                return true;
               
}

This seems to be working as I'm getting the image into the DB, now later I'm trying to pull the image out with the following code in PHP:

public function GetImages ()
{
        $result = mysql_query ( 'SELECT * FROM image');
        $array = array();
               
        while ( $row = mysql_fetch_assoc ( $result ) )
        {
                $ba = new Zend_Amf_Value_ByteArray ( base64_decode ( $row['byteArray'] ) );
                         
                $image = new Image ();
                $image->id = $row['id'];
                $image->bArray = $ba; //$ba->getData();
                       
                array_push ( $array, $image );
        }
               
        return ( $array );
}

This seems to be return an empty byte array.
Can anyone point me in the right direction on this?