/framework/core/db/DbPdo.php

http://zoop.googlecode.com/ · PHP · 60 lines · 37 code · 7 blank · 16 comment · 2 complexity · 0b4146d58d4b2609bfd86ac648ea1759 MD5 · raw file

  1. <?php
  2. class DbPdo extends DbConnection
  3. {
  4. function init()
  5. {
  6. if($this->params['file'][0] != '/')
  7. $this->params['file'] = app_dir . '/var/' . $this->params['file'];
  8. $this->conn = new PDO('sqlite:' . $this->params['file']);
  9. $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  10. $this->conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NAMED);
  11. }
  12. function escapeString($string)
  13. {
  14. return $this->conn->quote($string);
  15. }
  16. /**
  17. * Checks if a given table exists in the database
  18. *
  19. * @param string $name Name of the table to look for
  20. * @return boolean True if the table exists in this database
  21. */
  22. public function tableExists($name)
  23. {
  24. trigger_error("tableExists method not yet implemented in DbPdo");
  25. }
  26. /**
  27. * Returns an array of table names that exist in the database
  28. *
  29. * @return array Array of table names
  30. */
  31. public function getTableNames()
  32. {
  33. trigger_error("getTableNames is not yet implemented in DbPdo");
  34. }
  35. /**
  36. * Returns field information about the specified table
  37. *
  38. * @param string $tableName Name of the table to return information about
  39. */
  40. public function getTableFieldInfo($tableName)
  41. {
  42. trigger_error("getTableFieldInfo is not yet implemented in DbPdo");
  43. }
  44. function _query($sql)
  45. {
  46. $result = $this->conn->query($sql);
  47. return new DbPdoResult($this->conn, $result);
  48. }
  49. function getLastInsertId()
  50. {
  51. return $this->conn->lastInsertId();
  52. }
  53. }