1 | <?php |
||
18 | class PdoAdapter extends PDO |
||
19 | { |
||
20 | |||
21 | private $_inTransaction = false; |
||
22 | |||
23 | /** |
||
24 | * Do some basic setup for Firebird. |
||
25 | * o Force use of exceptions on error. |
||
26 | * o Force all metadata to lower case. |
||
27 | * Yii will behave in unpredicatable ways if |
||
28 | * metadata is not lowercase. |
||
29 | * o Ensure that table names are not prefixed to |
||
30 | * fieldnames when returning metadata. |
||
31 | * Finally call parent constructor. |
||
32 | * |
||
33 | */ |
||
34 | 7 | public function __construct($dsn, $username, $password, $driver_options = []) |
|
46 | |||
47 | /** |
||
48 | * Initiates a transaction |
||
49 | * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
||
50 | */ |
||
51 | public function beginTransaction($isolationLevel = null) |
||
52 | { |
||
53 | $this->setAttribute(PDO::ATTR_AUTOCOMMIT, false); |
||
54 | |||
55 | if ($isolationLevel === false) { |
||
56 | $this->_inTransaction = true; |
||
57 | return true; |
||
58 | } |
||
59 | |||
60 | if ($isolationLevel === null) { |
||
61 | $r = $this->exec("SET TRANSACTION"); |
||
62 | $success = ($r !== false); |
||
63 | if ($success) { |
||
64 | $this->_inTransaction = true; |
||
65 | } |
||
66 | return ($success); |
||
67 | } |
||
68 | |||
69 | $r = $this->exec("SET TRANSACTION ISOLATION LEVEL $isolationLevel"); |
||
70 | $success = ($r !== false); |
||
71 | if ($success) { |
||
72 | $this->_inTransaction = true; |
||
73 | } |
||
74 | return ($success); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Commits a transaction |
||
79 | * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
||
80 | */ |
||
81 | public function commit() |
||
82 | { |
||
83 | $r = $this->exec("COMMIT"); |
||
84 | $this->setAttribute(PDO::ATTR_AUTOCOMMIT, true); |
||
85 | $success = ($r !== false); |
||
86 | if ($success) { |
||
87 | $this->_inTransaction = false; |
||
88 | } |
||
89 | return ($success); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Rolls back a transaction |
||
94 | * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. |
||
95 | */ |
||
96 | public function rollBack() |
||
97 | { |
||
98 | $r = $this->exec("ROLLBACK"); |
||
99 | $this->setAttribute(PDO::ATTR_AUTOCOMMIT, true); |
||
100 | $success = ($r !== false); |
||
101 | if ($success) { |
||
102 | $this->_inTransaction = false; |
||
103 | } |
||
104 | return ($success); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Checks if inside a transaction |
||
109 | * @return bool <b>TRUE</b> if a transaction is currently active, and <b>FALSE</b> if not. |
||
110 | */ |
||
111 | public function inTransaction() |
||
115 | } |
||
116 |