Source for file query_result.php

Documentation is available at query_result.php

  1. <?php
  2. /**
  3. * Query Example
  4. *
  5. * This example uses the Query[Assoc, Objects, Row] functions to query a database and retrieve the
  6. * first result. The method shown in this example uses QueryRow but the other functions would
  7. * be used 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($db->QueryRow("SELECT * FROM tablename LIMIT 0,1", $row))
  24. {
  25. // Do something with the data in $row
  26. $field0 = $row[0];
  27. }
  28. else
  29. {
  30. die($db->GetLastError());
  31. }
  32. // Always good practice to close AbstractDB at the end of each script.
  33. $db->Close();
  34. ?>

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