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