Pdo.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class Core_Pdo {
  3. private $pdo;
  4. public function __construct(PDO $pdo) {
  5. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6. $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  7. $this->pdo = $pdo;
  8. }
  9. public function getPDO() {
  10. return $this->pdo;
  11. }
  12. //public PDOStatement PDO::prepare ( string $statement [, array $driver_options = array() ] )
  13. public function prepare($statement, $driver_options = array()) {
  14. return $this->pdo->prepare($statement, $driver_options);
  15. }
  16. // public PDOStatement query ( string $statement )
  17. public function query($statement) {
  18. return $this->pdo->query($statement);
  19. }
  20. // public string lastInsertId ([ string $name = NULL ] )
  21. public function lastInsertId() {
  22. return $this->pdo->lastInsertId();
  23. }
  24. // public int exec ( string $statement )
  25. public function exec($statement) {
  26. return $this->pdo->exec($statement);
  27. }
  28. // public string quote ( string $string [, int $parameter_type = PDO::PARAM_STR ] )
  29. public function quote($string, $parameter_type = PDO::PARAM_STR) {
  30. return $this->pdo->quote($string, $parameter_type);
  31. }
  32. }