Source for file fetch_result_column.php

Documentation is available at fetch_result_column.php

  1. <?php
  2. /**
  3. * FetchResultColumn Example
  4. *
  5. * This example uses the FetchResultColumn function to execute a query 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($rs = $db->Query("SELECT * FROM tablename"))
  23. {
  24. // Get the result
  25. $db->FetchResultColumn($rs, $column);
  26. // Do something with the data in $column.
  27. print_r($column);
  28. }
  29. else
  30. {
  31. die($db->GetLastError());
  32. }
  33. // Always good practice to close AbstractDB at the end of each script.
  34. $db->Close();
  35. ?>

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