4 Replies Latest reply on May 29, 2011 11:09 PM by Brenlei

    Problem passing parameters to a PHP remote service

    njtorrance

      I have a question about passing parameters to a PHP remote service from Flex.

       

      Consider the following query which works in MySql:

       

      SELECT r.restaurantId, name, city FROM restaurant AS r,

      restaurant_restaurant_category AS c

      WHERE r.restaurantId = c.restaurantId AND categoryId IN ( 6, 10 )

      GROUP BY restaurantId, name, city, phone ORDER BY name

       

      And this is the remote function (PHP) I am trying to call:

       

      public function getRestaurantsByCategories($categories) {

      $stmt = mysqli_prepare($this->connection,

      "SELECT r.restaurantId, name, city FROM restaurant AS r,

      restaurant_restaurant_category AS c

      WHERE r.restaurantId=c.restaurantId AND categoryId IN (?)

      GROUP BY restaurantId, name, city, phone ORDER BY name");

      // some other stuff here

      }

       

      What I cannot figure out is what I need to pass to PHP from Flex in order to execute the query pasted above. E.g. I've tried

       

      var array1:Array = new Array();

      array1[0] = 6;

      array1[1] = 10;

       

      and I've tried

       

      var string1:String = new String("6,10");

       

      calling the remote function (after setting the input type as appropriate) like so

       

      remoteService.getRestaurantsByCategories(array1);

      or so

      remoteService.getRestaurantsByCategories(string1);

       

      but both of these only return matches for categoryId=6.

       

      What is the right way to pass the parameters to PHP so that the query gets executed for both categoryIds?

       

      Thanks for any help, folks.