1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\Database\Drivers;
9:
10: use Nette;
11:
12:
13: 14: 15: 16: 17:
18: class OdbcDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
19: {
20:
21:
22:
23:
24: 25: 26:
27: public function delimite($name)
28: {
29: return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
30: }
31:
32:
33: 34: 35:
36: public function formatBool($value)
37: {
38: return $value ? '1' : '0';
39: }
40:
41:
42: 43: 44:
45: public function formatDateTime(\DateTime $value)
46: {
47: return $value->format('#m/d/Y H:i:s#');
48: }
49:
50:
51: 52: 53:
54: public function formatLike($value, $pos)
55: {
56: $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
57: return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
58: }
59:
60:
61: 62: 63:
64: public function applyLimit(& $sql, $limit, $offset)
65: {
66: if ($limit >= 0) {
67: $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
68: }
69:
70: if ($offset) {
71: throw new Nette\InvalidArgumentException('Offset is not implemented in driver odbc.');
72: }
73: }
74:
75:
76: 77: 78:
79: public function normalizeRow($row, $statement)
80: {
81: return $row;
82: }
83:
84:
85:
86:
87:
88: 89: 90:
91: public function getTables()
92: {
93: throw new Nette\NotImplementedException;
94: }
95:
96:
97: 98: 99:
100: public function getColumns($table)
101: {
102: throw new Nette\NotImplementedException;
103: }
104:
105:
106: 107: 108:
109: public function getIndexes($table)
110: {
111: throw new Nette\NotImplementedException;
112: }
113:
114:
115: 116: 117:
118: public function getForeignKeys($table)
119: {
120: throw new Nette\NotImplementedException;
121: }
122:
123:
124: 125: 126:
127: public function isSupported($item)
128: {
129: return $item === self::SUPPORT_COLUMNS_META;
130: }
131:
132: }
133: