1: <?php
2:
3: namespace PHPixie\Database\Driver\PDO;
4:
5: abstract class Adapter
6: {
7: protected $config;
8: protected $connection;
9: protected $savepoint = 0;
10: protected $isTransactionActive = false;
11:
12: public function __construct($config, $connection)
13: {
14: $this->config = $config;
15: $this->connection = $connection;
16: }
17:
18: public function insertId()
19: {
20: $id = $this->connection->pdo()->lastInsertId();
21:
22: if (empty($id))
23: throw new \PHPixie\Database\Exception('Cannot get last insert id, probably no rows have been inserted yet.');
24:
25: return $id;
26: }
27:
28: public function rollbackTransactionTo($savepoint)
29: {
30: $this->connection->execute('ROLLBACK TO '.$savepoint);
31: }
32:
33: public function createTransactionSavepoint($name)
34: {
35: $this->connection->execute('SAVEPOINT '.$name);
36: }
37:
38: abstract public function listColumns($table);
39:
40: }
41: