AS3 code
<fx:Declarations>
<!-- this is the RemoteObject used to make the RPC calls -->
<mx:RemoteObject id="myRemote" destination="MyService" source="MyService"
endpoint="http://localhost/amfphp/gateway.php"
showBusyCursor="true"/>
</fx:Declarations>
protected function button1_clickHandler(event:MouseEvent):void
{
var aut:VOAuthor; // value object class
aut = new VOAuthor();
aut.id_aut = 3;
aut.fname_aut = "test";
aut.lname_aut = "123";
myRemote.saveData(aut);
}
Receving PHP code
public function saveData($author)
{
$mysql = mysql_connect("localhost", "mx112", "xxxxxx");
mysql_select_db("flex360");
$query = "INSERT INTO authors (fname_aut, lname_aut) VALUES ('".$author->fname_aut."', '".$author->lname_aut."')";
$result = mysql_query($query);
return $author;
}
<?php
class VOAuthor {
public $id_aut;
public $fname_aut;
public $lname_aut;
var $_explicitType="org.corlan.VOAuthor";}
?>
Flex network monitor response : Raw view
{lname_aut=123, _explicitType=org.corlan.VOAuthor, fname_aut=test, id_aut=3}
but If I do this at the end of the php code
return $author->lname_aut;
network monitor response is NULL
so the problem is I can print the array but how to cast tht array to a known php type ? After 5 days I finnaly figured out flex and mysql using amfphp any one please help ?
if you are using amfphp and Flash you have to register your VOs:
import org.corlan.VOAuthor;
// ...
registerClassAlias("org.corlan.VOAuthor", VOAuthor);
only then does php recognize the objects you're sending it from ActionScript.