pdo = new \PDO($connection_string, $user, $password); $this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } /** * @return \PDO Connection to database */ function getPDO() { return $this->pdo; } /** * Find all tables in database. * * @return array The array of table names */ function allTables() { $result = $this->pdo->query('SHOW TABLES'); $schemas = $result->fetchAll(\PDO::FETCH_COLUMN); return $schemas; } function prepare($sql) { return $this->pdo->prepare($sql); } function beginTransaction() { $this->pdo->beginTransaction(); } function commit() { $this->pdo->commit(); } function rollback() { $this->pdo->rollback(); } function errorCode() { return $this->pdo->errorCode(); } function errorInfo() { return $this->pdo->errorInfo(); } function query($sql) { return $this->pdo->query($sql); } public function lastInsertId() { return $this->pdo->lastInsertId(); } }