1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20:
21: class OciDriver extends Object implements ISupplementalDriver
22: {
23:
24: private $connection;
25:
26:
27: private $fmtDateTime;
28:
29:
30:
31: public function __construct(Connection $connection, array $options)
32: {
33: $this->connection = $connection;
34: $this->fmtDateTime = isset($options['formatDateTime']) ? $options['formatDateTime'] : 'U';
35: }
36:
37:
38:
39:
40:
41:
42:
43: 44: 45:
46: public function delimite($name)
47: {
48:
49: return '"' . str_replace('"', '""', $name) . '"';
50: }
51:
52:
53:
54: 55: 56:
57: public function formatDateTime(DateTime $value)
58: {
59: return $value->format($this->fmtDateTime);
60: }
61:
62:
63:
64: 65: 66:
67: public function formatLike($value, $pos)
68: {
69: throw new NotImplementedException;
70: }
71:
72:
73:
74: 75: 76:
77: public function applyLimit(&$sql, $limit, $offset)
78: {
79: if ($offset > 0) {
80:
81: $sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
82: . ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
83: . ') WHERE "__rnum" > '. (int) $offset;
84:
85: } elseif ($limit >= 0) {
86: $sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
87: }
88: }
89:
90:
91:
92: 93: 94:
95: public function normalizeRow($row, $statement)
96: {
97: return $row;
98: }
99:
100:
101:
102:
103:
104:
105:
106: 107: 108:
109: public function getTables()
110: {
111: $tables = array();
112: foreach ($this->connection->query('SELECT * FROM cat', PDO::FETCH_NUM) as $row) {
113: if ($row[1] === 'TABLE' || $row[1] === 'VIEW') {
114: $tables[] = array(
115: 'name' => $row[0],
116: 'view' => $row[1] === 'VIEW',
117: );
118: }
119: }
120: return $tables;
121: }
122:
123:
124:
125: 126: 127:
128: public function getColumns($table)
129: {
130: throw new NotImplementedException;
131: }
132:
133:
134:
135: 136: 137:
138: public function getIndexes($table)
139: {
140: throw new NotImplementedException;
141: }
142:
143:
144:
145: 146: 147:
148: public function getForeignKeys($table)
149: {
150: throw new NotImplementedException;
151: }
152:
153:
154:
155: 156: 157:
158: public function isSupported($item)
159: {
160: return $item === self::META;
161: }
162:
163: }
164: