2010年11月29日星期一

[fw-webservices] ZendAMF ByteArray

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?
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZendAMF-ByteArray-tp3064702p3064702.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

没有评论: