1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19:
20: class NPdoMsSqlDriver extends NObject implements ISupplementalDriver
21: {
22:
23: private $connection;
24:
25:
26:
27: public function __construct(NConnection $connection, array $options)
28: {
29: $this->connection = $connection;
30: }
31:
32:
33:
34:
35:
36:
37:
38: 39: 40:
41: public function delimite($name)
42: {
43: 44: return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
45: }
46:
47:
48:
49: 50: 51:
52: public function formatDateTime(DateTime $value)
53: {
54: return $value->format("'Y-m-d H:i:s'");
55: }
56:
57:
58:
59: 60: 61:
62: public function formatLike($value, $pos)
63: {
64: $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
65: return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
66: }
67:
68:
69:
70: 71: 72:
73: public function applyLimit(&$sql, $limit, $offset)
74: {
75: 76: if ($limit >= 0) {
77: $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
78: }
79:
80: if ($offset) {
81: throw new NotImplementedException('Offset is not implemented.');
82: }
83: }
84:
85:
86:
87: 88: 89:
90: public function normalizeRow($row, $statement)
91: {
92: return $row;
93: }
94:
95: }
96: