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