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