Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 如何在Flex PHP服务中提供int[]参数_Apache Flex_Flex4 - Fatal编程技术网

Apache flex 如何在Flex PHP服务中提供int[]参数

Apache flex 如何在Flex PHP服务中提供int[]参数,apache-flex,flex4,Apache Flex,Flex4,我的Flex服务呼叫返回Null。有人能告诉我哪里出了问题吗 数据库: 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:

我的Flex服务呼叫返回Null。有人能告诉我哪里出了问题吗

数据库:

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服务方法:

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测试查询:

<?php 
    include('UserService.php'); 
    $o = new UserService(); 
?>

<pre>
<?php 
    var_dump($o->getAllUserByStatus(array('Active','Passive')));
?>
</pre>
Flex应用程序(返回Null,原因):



如果event.result不是ArrayCollection,则尝试将其强制转换为一个将导致空赋值。尝试将acUser设置为数组实例,并将event.result转换为数组。

acUser=event.result为数组;//将Array类型的值隐式强制为不相关的mx类型时出错。集合:ArrayCollection。很抱歉这没用。这就是为什么我的接受度很低,并不是很多答案都有效。@user611468我不认为答案不起作用。我告诉过你让acUser也成为数组的一个实例。你没有阅读说明,所以现在你有一个初学者的错误,解决方案是如此简单,不值得张贴。您是否已验证event.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)
<?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>