QueryColumn example.

  1. <?php
  2. /**
  3. * QueryColumn Example
  4. *
  5. * This example uses the QueryColumn function to query a database and retrieve the values in the
  6. * first column of the result set.
  7. * @package AbstractDB
  8. * @author Pacific-Cybersoft
  9. * @copyright (C) 2005 Pacific-Cybersoft. All Rights Reserved.
  10. * @version v 1.0.2
  11. * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
  12. */
  13.  
  14. /**
  15. * Include the AbstractDB main class.
  16. */
  17. include("../abstractdb.class.php");
  18.  
  19. // Instatiate AbstractDB
  20. $db = new AbstractDB(array("ConnectionString"=>"mysql://username:password@localhost/mydatabase"));
  21. // Execute a Query
  22. if($db->QueryColumn("SELECT * FROM tablename", $column))
  23. {
  24. // Do something with the data in $column
  25. foreach($column as $key=>$value)
  26. echo("Value at index $k is $v\r\n");
  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:01 +1100 by phpDocumentor 1.3.0RC3