odbcAdapter.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  4. * @copyright (c) 2003 amfphp.org
  5. * @package flashservices
  6. * @subpackage adapters
  7. * @version $Id: odbcAdapter.php,v 1.2 2005/07/22 10:58:09 pmineault Exp $
  8. */
  9. require_once(AMFPHP_BASE . "shared/adapters/RecordSetAdapter.php");
  10. class odbcAdapter extends RecordSetAdapter {
  11. /**
  12. * Constructor method for the adapter. This constructor implements the setting of the
  13. * 3 required properties for the object.
  14. *
  15. * The body of this method was provided by Mario Falomir... Thanks.
  16. *
  17. * @param resource $d The datasource resource
  18. */
  19. function odbcAdapter($d) {
  20. parent::RecordSetAdapter($d);
  21. // count number of fields
  22. $fieldcount = odbc_num_fields($d);
  23. // grab the number of fields
  24. // loop over all of the fields
  25. for($i = 0; $i < $fieldcount; $i++) {
  26. // decode each field name ready for encoding when it goes through serialization
  27. // and save each field name into the array
  28. $this->columns[] = odbc_field_name($d, $i + 1);
  29. }
  30. if(odbc_num_rows($d) > 0)
  31. {
  32. $line = odbc_fetch_row($d, 0);
  33. do {
  34. $this->rows[] = $line;
  35. } while ($line = odbc_fetch_row($d));
  36. }
  37. }
  38. }
  39. ?>