AS3代碼鑄造從FLEX到PHP
<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代碼
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的網絡監控響應:原始視圖
{lname_aut=123, _explicitType=org.corlan.VOAuthor, fname_aut=test, id_aut=3}
,但如果我這樣做,在結束php代碼
return $author->lname_aut;
網絡監視器響應爲NULL
所以問題是我可以打印數組但是如何將數組轉換爲已知的php類型? 5天后,我finnaly想出flex和mysql使用amfphp任何人請幫助?
tx @pkyeck我會嘗試你的代碼的方式我試過這個$ author ['fname_aut']這工作對我來說,但因爲我使用一個簡單的例如,它好嗎如何複雜的系統發票系統我可能必須在一個遠程請求中發送多個類如何處理這段時間的數據?請諮詢 – Fara 2012-02-01 04:20:55