DataOp_2.php 原始碼
< ?php
class DataOp_2
{
var $dbhost = "localhost";
var $db = "test";
var $table = "tbl_address_book";
var $user = "root";
var $password = "admin";
function DataOp_2(){
mysql_connect($this->dbhost, $this->user, $this->password);
mysql_query("SET NAMES 'utf8'");
mysql_select_db($this->db);
$this->methodTable = array(
"getAllData"=>array(
"access"=>"remote"
)
);
}
function getAllData(){
$sql = sprintf("select * from `%s`", $this->table);
return mysql_query($sql);
}
}
?>
Flash AS3
import QopDump; // just prompt
var nc:NetConnection = new NetConnection();
nc.connect('http://localhost/amfphp/gateway.php');
var responder:Responder = new Responder(onResult, onError);
nc.call('myremoting.DataOp_2.getAllData', responder);
function onResult(re:Object):void {
QopDump.echo(re);
}
function onError(er:Object):void {
QopDump.echo(er);
}
正常執行的結果:
serverInfo:
version:1
id:
serviceName:PageAbleResult
initialData:
[0]:
[0]:3
[1]:哈利
[2]:0987654321
[3]:台北市大安區
[1]:
[0]:4
[1]:凱蒂貓
[2]:0987654322
[3]:宜蘭縣礁溪鄉
[2]:
[0]:6
[1]:小叮噹
[2]:0987654323
[3]:台東縣知本溫泉旁
columnNames:
[0]:id
[1]:name
[2]:phone
[3]:address
cursor:1
totalCount:3
方法名稱錯誤的結果:
line:171
description:The method {getAll} was not declared in the meta data for class {DataOp_2}.
level:User Error
details:C:\wamp163\www\amfphp\amf-core\app\Actions.php
code:AMFPHP_UNDECLARED_METHOD
沒有留言:
張貼留言