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