Source for file field_count.php

Documentation is available at field_count.php

  1. <?php
  2. /**
  3. * GetFieldCount Example
  4. *
  5. * This example uses the GetFieldCount method to get the number 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 number of affected rows
  24. $fieldcount = $db->GetFieldCount($rs);
  25. // Free Result
  26. $db->FreeResult($rs);
  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:23 +1100 by phpDocumentor 1.3.0RC3