Source for file query_field.php

Documentation is available at query_field.php

  1. <?php
  2. /**
  3. * QueryField Example
  4. *
  5. * This example uses the QueryField function to query a database and retrieve the value of the
  6. * first column of the first row of a 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->QueryField("SELECT * FROM tablename LIMIT 0,1", $field))
  23. {
  24. // Do something with $field
  25. echo($field);
  26. }
  27. else
  28. {
  29. die($db->GetLastError());
  30. }
  31. // Always good practice to close AbstractDB at the end of each script.
  32. $db->Close();
  33. ?>

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