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 MsSqlDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
24: {
25:
26: private $connection;
27:
28:
29:
30: public function __construct(Nette\Database\Connection $connection, array $options)
31: {
32: $this->connection = $connection;
33: }
34:
35:
36:
37:
38:
39:
40:
41: 42: 43:
44: public function delimite($name)
45: {
46:
47: return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
48: }
49:
50:
51:
52: 53: 54:
55: public function formatBool($value)
56: {
57: return $value ? '1' : '0';
58: }
59:
60:
61:
62: 63: 64:
65: public function formatDateTime(\DateTime $value)
66: {
67: return $value->format("'Y-m-d H:i:s'");
68: }
69:
70:
71:
72: 73: 74:
75: public function formatLike($value, $pos)
76: {
77: $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
78: return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
79: }
80:
81:
82:
83: 84: 85:
86: public function applyLimit(&$sql, $limit, $offset)
87: {
88: if ($limit >= 0) {
89: $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
90: }
91:
92: if ($offset) {
93: throw new Nette\NotImplementedException('Offset is not implemented.');
94: }
95: }
96:
97:
98:
99: 100: 101:
102: public function normalizeRow($row, $statement)
103: {
104: return $row;
105: }
106:
107:
108:
109:
110:
111:
112:
113: 114: 115:
116: public function getTables()
117: {
118: throw new Nette\NotImplementedException;
119: }
120:
121:
122:
123: 124: 125:
126: public function getColumns($table)
127: {
128: throw new Nette\NotImplementedException;
129: }
130:
131:
132:
133: 134: 135:
136: public function getIndexes($table)
137: {
138: throw new Nette\NotImplementedException;
139: }
140:
141:
142:
143: 144: 145:
146: public function getForeignKeys($table)
147: {
148: throw new Nette\NotImplementedException;
149: }
150:
151:
152:
153: 154: 155:
156: public function isSupported($item)
157: {
158: return $item === self::SUPPORT_COLUMNS_META;
159: }
160:
161: }
162: