开发者

Configuring propel return type for flex

开发者 https://www.devze.com 2023-03-23 03:18 出处:网络
I use wamp server and Propel.I have written my service using Propel but when I want to connect the data returned from the service Flex cannot recognize the return type.

I use wamp server and Propel.I have written my service using Propel but when I want to connect the data returned from the service Flex cannot recognize the return type.

This is the php code that I wrote

<?php 

// Include the main Propel script
require_once 'C:/wamp/propel/runtime/lib/Propel.php';

// Initialize Propel with the runtime configuration
Propel::init("C:/wamp/www/school/build/conf/school-conf.php");

// Add the generated 'classes' directory to the include path
set_include_path("C:/wamp/www/school/build/classes" . PATH_SEPARATOR . get_include_path());

class TeacherService { 
function getTeachers()
{

 $allTeachers=TeacherQuery::create()->find();

 $teachers=array();
 foreach($allTeachers as $teacher1)
 {

  array_push($teachers, $teacher1); 

 }

return $teachers;
}
}
?>

I wanto to display the information of teacers in a datagr开发者_如何学Goid yet when I choose to auto-detect the return type it gives the error

'teacher' cannot be set to the data type "StdClass" because it has no properties.

How can I let flex know the properties of teacher rows returned by propel?


@www.Flextras.com Propel is a PHP ORM framework.

If you want serialization to work on your php class you would have to have something like this

var $_explicitType = "path.to.classes.Teacher";

and on your Flex side VO's you would have to have something like this.

[Bindable]
[RemoteClass(alias="path.to.classes.Teacher")]

This is assuming you are using AMF. Also in your AMF endpoint you have to specify the mapping, so for example I would have something like this in my endpoint file.

$server->setClassMap('path.to.classes.Teacher' , 'path\to\classes\Teacher');

This lets your endpoint know that when it sees a class with the matching descriptor, which class on the PHP side it should be deserialized to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号