0 Replies Latest reply on Mar 10, 2010 7:36 AM by flex_n00b

    Using VO with AMFPHP Flex

    flex_n00b

      Hi,

       

      I have made the following ActionScript class, Person.as for the Flex Application. This gets the details about a person from a Form I have in the Application.

       

       

      package info.mysite
      {
          [RemoteClass(alias="info.mysite.Person")]
          [Bindable]
          public class Person {
      
              public var username:String;
              public var password:String;
              public var fname:String;
              public var lname:String;
              public var email:String;
              public var gender:String;
              public var bdate:Date;
              
          }
      
      }
      

       

      I am sending this data using a Remote Object to AMFPHP. Here are my services-

       

      <?php
      class Person {
      
          public $username;
          public $password;
          public $fname;
          public $lname;
          public $email;
          public $gender;
          public $bdate;
          
      
          // explicit actionscript class
          var $_explicitType = "info.mysite.Person";
      }
      ?>
      

       

      Person.php

       

      and my main Service-

       

      <?php
      
      /**
       * Service to feed registration data
       * 
       */
      require_once ('Person.php');
      require_once ('db.php');
      
      
      
      class Feed
      {
      
          /**
           * Adds a new user
           * @returns Status of operation 
           */
      
          public function feedData(Person $a) {
              
              
               
                             //Connect to the DB
      
                             $dbc=mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
      
                            
                             
                             $query="insert into users(username,password) values($a->username,$a->password)";
                             
                             if(mysqli_query($dbc,$query))
                             return "true";
                             
                             else return "false";
                             
                             mysqli_close($dbc);
                            
              
              
              
              
              
              
              
              
                  
          }
          
          
              
      }
      
      ?>
      

       

      When I test the service, AMFPHP reports error as argument given as array, expected an object of Person type. I am calling the method in Flex as myRemoteObject.feedData(<object of Person class>)

       

      Where am I going wrong?