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:
23: class OdbcDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
24: {
25:
26: public $supports = array('meta' => TRUE);
27:
28:
29: private $connection;
30:
31:
32:
33: public function __construct(Nette\Database\Connection $connection, array $options)
34: {
35: $this->connection = $connection;
36: }
37:
38:
39:
40:
41:
42:
43:
44: 45: 46:
47: public function delimite($name)
48: {
49: return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
50: }
51:
52:
53:
54: 55: 56:
57: public function formatDateTime(\DateTime $value)
58: {
59: return $value->format("#m/d/Y H:i:s#");
60: }
61:
62:
63:
64: 65: 66:
67: public function formatLike($value, $pos)
68: {
69: $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
70: return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
71: }
72:
73:
74:
75: 76: 77:
78: public function applyLimit(&$sql, $limit, $offset)
79: {
80:
81: if ($limit >= 0) {
82: $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
83: }
84:
85: if ($offset) {
86: throw new Nette\InvalidArgumentException('Offset is not implemented in driver odbc.');
87: }
88: }
89:
90:
91:
92: 93: 94:
95: public function normalizeRow($row, $statement)
96: {
97: return $row;
98: }
99:
100: }
101: