stublackett Posted August 1, 2011 Share Posted August 1, 2011 Hi, I'm asking this on behalf of a colleague who has hit a bit of a programming brick wall His Flex Service Call is returning Null can anybody tell me where he may be going wrong? Database: user_id: 1 user_name: stephen user_password: qwerty status: Active user_id: 2 user_name: john user_password: qwerty status: Passive user_id: 3 user_name: marice user_password: qwerty status: Awaiting user_id: 4 user_name: maria user_password: qwerty status: Passive PHP Service Method: <?php public function getAllUserByStatus($arrStatus) { $rows = array(); foreach ($arrStatus as $item) { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename WHERE status=?"); $this->throwExceptionOnError(); mysqli_stmt_bind_param($stmt, 's', $item); $this->throwExceptionOnError(); mysqli_stmt_execute($stmt); $this->throwExceptionOnError(); mysqli_stmt_bind_result($stmt, $row->user_id, $row->user_name, $row->user_password, $row->status); while (mysqli_stmt_fetch($stmt)) { $rows[] = $row; $row = new stdClass(); mysqli_stmt_bind_result($stmt, $row->user_id, $row->user_name, $row->user_password, $row->status); } mysqli_stmt_free_result($stmt); } mysqli_close($this->connection); return $rows; } ?> PHP Test Query: <?php include('UserService.php'); $o = new UserService(); ?> <pre> <?php var_dump($o->getAllUserByStatus(array('Active','Passive'))); ?> </pre> PHP Test Result: array 0 => object(stdClass)[4] public 'user_id' => int 1 public 'user_name' => string 'stephen' (length=7) public 'user_password' => string 'qwerty' (length=6) public 'status' => string 'Active' (length=6) 1 => object(stdClass)[5] public 'user_id' => int 2 public 'user_name' => string 'john' (length=4) public 'user_password' => string 'qwerty' (length=6) public 'status' => string 'Passive' (length=7) 2 => object(stdClass)[3] public 'user_id' => int 4 public 'user_name' => string 'maria' (length=5) public 'user_password' => string 'qwerty' (length=6) public 'status' => string 'Passive' (length=7) Flex Application (Returns Null, Why): <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:userservice="services.userservice.*" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.events.FlexEvent; import mx.rpc.events.ResultEvent; protected var acUser:ArrayCollection; protected function application1_creationCompleteHandler(event:FlexEvent):void { getAllUserByStatusResult.token = userService.getAllUserByStatus(new ArrayCollection(new Array(['Active','Passive']))); getAllUserByStatusResult.addEventListener(ResultEvent.RESULT, getAllUserByStatusResultHandler); } protected function getAllUserByStatusResultHandler(event:ResultEvent):void { acUser = event.result as ArrayCollection; // Break Point to examine acUser } ]]> </fx:Script> <fx:Declarations> <s:CallResponder id="getAllUserByStatusResult"/> <userservice:UserService id="userService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> </s:Application> Any help on this much appreciated, As he's getting a little hacked off with it right now Quote Link to comment https://forums.phpfreaks.com/topic/243491-fao-any-flex-gurus-how-do-you-supply-the-parameters-int-in-a-php-service/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.