FetchNextResult example.

  1. <?php
  2. /**
  3. * FetchNextResult Example
  4. *
  5. * This example uses the FetchNextResult[Assoc, Object, Row] functions to retrieve query results.
  6. * The method shown in this example uses FetchNextResultRow but the other functions would be used
  7. * in the same way.
  8. * @package AbstractDB
  9. * @author Pacific-Cybersoft
  10. * @copyright (C) 2005 Pacific-Cybersoft. All Rights Reserved.
  11. * @version v 1.0.2
  12. * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
  13. */
  14.  
  15. /**
  16. * Include the AbstractDB main class.
  17. */
  18. include("../abstractdb.class.php");
  19.  
  20. // Instatiate AbstractDB
  21. $db = new AbstractDB(array("ConnectionString"=>"mysql://username:password@localhost/mydatabase"));
  22. // Execute a Query
  23. if($rs = $db->Query("SELECT * FROM tablename"))
  24. {
  25. // Loop through results
  26. while($db->FetchNextResultRow($rs, $row))
  27. {
  28. // Do something with the data in $row.
  29. print_r($row);
  30. }
  31. // Free Result
  32. $db->FreeResult($rs);
  33. }
  34. else
  35. {
  36. die($db->GetLastError());
  37. }
  38. // Always good practice to close AbstractDB at the end of each script.
  39. $db->Close();
  40. ?>

Documentation generated on Wed, 16 Mar 2005 23:16:51 +1100 by phpDocumentor 1.3.0RC3