2 Replies Latest reply on Jul 21, 2010 2:09 PM by UbuntuPenguin

    Passing multiple values of same column in php Query


      Hi. I am a beginner in Flex and have a question. I have a php data service which has a custom function which looks like this:


      public function getCombined_TodayStatsByMultipleQuery($symbol) {


                     $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where Symbol IN (?)");



                     mysqli_stmt_bind_param($stmt, 's', $symbol);






                     mysqli_stmt_bind_result($stmt, $row->Symbol, $row->Target,$row->LookbackDate, $row->LookbackName, $row->Indicator, $row->Bin,$row->MinInd, $row->MaxInd, $row->AvgTarget, $row->Gain, $row->Loss,$row->Median, $row->Value, $row->id);


                     while (mysqli_stmt_fetch($stmt)) {

                     $row->LookbackDate = new DateTime($row->LookbackDate);

                           $rows[] = $row;

                           $row = new stdClass();

                     mysqli_stmt_bind_result($stmt, $row->Symbol, $row->Target,$row->LookbackDate, $row->Indicator, $row->Bin, $row->MinInd,$row->MaxInd, $row->AvgTarget, $row->Gain, $row->Loss, $row->Median,$row->Value, $row->id, $row->LookbackName);





                  return $rows;



      And my dataGrid creation complete handler function looks like this:
      protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
      var symbol:String = "XOM";
      getCombined_TodayStatsByMultipleQueryResult.token = combinedTodayStatsService.getCombined_TodayStatsByMultipleQuery(/*Enter value(s) for */ symbol);
      Currently, the input type for the data service is configured as "Symbol" Object of the SQL Table and the return type is configured as a Custom Data Type[]. How do I pass an string consisting of more than one Symbol name i.e., XOM,AA,BAC,etc... in the query ?
      For checking the operation,I have tried using
      var symbol:String = "AA,XOM"
      var symbol:String = " 'AA','XOM' "
      var symbol:String = " (AA,XOM)".
      But, it does not work. It looks like I am missing something trivial, but I am not able to figure it out. Excuse me if this a noob question. PLEASE help.......
      Thanks in advance.

        • 2. Re: Passing multiple values of same column in php Query
          nmkFlex4u Level 1

          @ubuntupenguin Thanx for your prompt reply.


          I am currently able to store all the necessary symbols in an array. But, How do I query for multiple symbols in the SQL Query ?

          I have an array symArr[] which consists of all the symbols I need to query from the database. So, How should I write the SQL Query is my question.


          I could have created a string which looks something like this from the symArr[] array:




          But, the problem would be when I try to query these symbols in the php data service using "SELECT * FROM TABLENAME WHERE SYMBOL IN (?)"

          where the variable $symbol is the populated string (XOM,AA,BAC,BB,BBC,.... ). So, to rephrase my question, Could I use SELECT * FROM TABLENAME WHERE SYMBOL IN (?) to query for Multiple symbols or is there a better approach.


          Thanx in advance.