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