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: class OdbcDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
23: {
24:
25: private $connection;
26:
27:
28: public function __construct(Nette\Database\Connection $connection, array $options)
29: {
30: $this->connection = $connection;
31: }
32:
33:
34:
35:
36:
37: 38: 39:
40: public function delimite($name)
41: {
42: return '[' . str_replace(array('[', ']'), array('[[', ']]'), $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("#m/d/Y H:i:s#");
61: }
62:
63:
64: 65: 66:
67: public function formatLike($value, $pos)
68: {
69: $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
70: return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
71: }
72:
73:
74: 75: 76:
77: public function applyLimit(& $sql, $limit, $offset)
78: {
79: if ($limit >= 0) {
80: $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
81: }
82:
83: if ($offset) {
84: throw new Nette\InvalidArgumentException('Offset is not implemented in driver odbc.');
85: }
86: }
87:
88:
89: 90: 91:
92: public function normalizeRow($row, $statement)
93: {
94: return $row;
95: }
96:
97:
98:
99:
100:
101: 102: 103:
104: public function getTables()
105: {
106: throw new Nette\NotImplementedException;
107: }
108:
109:
110: 111: 112:
113: public function getColumns($table)
114: {
115: throw new Nette\NotImplementedException;
116: }
117:
118:
119: 120: 121:
122: public function getIndexes($table)
123: {
124: throw new Nette\NotImplementedException;
125: }
126:
127:
128: 129: 130:
131: public function getForeignKeys($table)
132: {
133: throw new Nette\NotImplementedException;
134: }
135:
136:
137: 138: 139:
140: public function isSupported($item)
141: {
142: return $item === self::SUPPORT_COLUMNS_META;
143: }
144:
145: }
146: