Source for file field_names.php

Documentation is available at field_names.php

  1. <?php
  2. /**
  3. * GetFieldNames Example
  4. *
  5. * This example uses the GetFieldNames method to get the names of fields in a result set.
  6. * @package AbstractDB
  7. * @author Pacific-Cybersoft
  8. * @copyright (C) 2005 Pacific-Cybersoft. All Rights Reserved.
  9. * @version v 1.0.2
  10. * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
  11. */
  12.  
  13. /**
  14. * Include the AbstractDB main class.
  15. */
  16. include("../abstractdb.class.php");
  17.  
  18. // Instatiate AbstractDB
  19. $db = new AbstractDB(array("ConnectionString"=>"mysql://username:password@localhost/mydatabase"));
  20. // Execute a Query
  21. if($rs = $db->Query("SELECT * FROM tablename"))
  22. {
  23. // Get the field names
  24. $db->GetFieldNames($rs, $fields);
  25. // Do something with the field names
  26. foreach($fields as $field)
  27. {
  28. echo($field)
  29. }
  30. // Free Result
  31. $db->FreeResult($rs);
  32. }
  33. else
  34. {
  35. die($db->GetLastError());
  36. }
  37. // Always good practice to close AbstractDB at the end of each script.
  38. $db->Close();
  39. ?>

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