pdoAdapter.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * This Adapter translates the specific Database type links to the data and pulls the data into very
  4. * specific local variables to later be retrieved by the gateway and returned to the client.
  5. *
  6. * pdoAdapter is a contribution of Andrea Giammarchi
  7. *
  8. * Now using fast serialization
  9. *
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @copyright (c) 2003 amfphp.org
  12. * @package flashservices
  13. * @subpackage adapters
  14. * @version $Id: sqliteAdapter.php,v 1.1 2005/07/05 07:56:29 pmineault Exp $
  15. */
  16. require_once(AMFPHP_BASE . "shared/adapters/RecordSetAdapter.php");
  17. class pdoAdapter extends RecordSetAdapter
  18. {
  19. function pdoAdapter($d) {
  20. parent::RecordSetAdapter($d);
  21. $line = $d->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 0);
  22. if($line != null)
  23. {
  24. $colNum = 0;
  25. $firstLine = array();
  26. foreach($line as $k => $v)
  27. {
  28. $this->columns[$colNum] = $k;
  29. $firstLine[] = $v;
  30. $colNum++;
  31. }
  32. $lastLines = $d->fetchAll(PDO::FETCH_NUM);
  33. if($lastLines == NULL)
  34. {
  35. $this->rows = array($firstLine);
  36. }
  37. else
  38. {
  39. array_unshift($lastLines, $firstLine);
  40. $this->rows = $lastLines;
  41. }
  42. }
  43. }
  44. }
  45. ?>