Welcome, Guest
  • Author Topic: AMFPHP - passing an SQLite recordset to Flash via Remoting  (Read 4596 times)

    Adam Schroeder

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • EvilFree!
    In order to pass recordset data back to flash in AMFPHP a recordset filter needs to be created.  AMFPHP comes with several filters by default, but does not include one for SQLITE.  

    I've modified the MYSQL filter to act as the SQLITE filter.  So far it seems to be working.  :)

    If anyone else want this.  Create a file named "sqliteRecordSet.php" and place it within "flash services\sql" and use this code:

    Code: [Select]

    <?php<br>// Modified mysqlRecordSet.php by changing the relevant<br>// lines to work with an SQLite database  - AS<br><br>// original section of writeRecordSet method JC<br>// this makes it easy for developers edit results<br>// with touching the more important parts of the PHP Gateway JC<br>// maybe use different methods to format recordset<br>// different ways depending on something??? JC<br><br>class sqliteRecordSet<br>{<br>  var $initialData = array();<br>  var $columnNames = array();<br><br>  function sqliteRecordSet($d)<br>  {<br>      // grab all of the rows<br>      while ($line = sqlite_fetch_array($d, SQLITE_NUM)) {<br>        // decode each value ready for encoding when it goes through serialization<br>        foreach($line as $key => $value) {<br>            $line[$key] = utf8_decode($value);<br>        }<br>        // add each row to the initial data array<br>        $this->initialData[] = $line;<br>      } <br>      // grab the number of fields<br>      $fieldcount = sqlite_num_fields($d);<br>      // loop over all of the fields<br>      for($i=0; $i<$fieldcount; $i++)  {<br>        // decode each field name ready for encoding when it goes through serialization<br>        // and save each field name into the array<br>        $this->columnNames[$i] = utf8_decode(sqlite_field_name($d, $i));<br>      }<br>      $this->numRows = sqlite_num_rows($d);<br>  }<br>}<br>?>

    Patrick Mineault

    • Server what's that
    • *
    • Posts: 3
      • View Profile
    Do you mind if I include this into the next version of AMFPHP? Full credit will be given, of course!

    Adam Schroeder

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • EvilFree!
    Of course you can use it.

    I can't take to much credit for it... I only changed like 2 lines from the MYSQL version.

    I'm on the AMFPHP sourceforge mailing list as well.  I'm excited about your contributions!