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