Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • MsSqlDriver
  • MySqlDriver
  • OciDriver
  • OdbcDriver
  • PgSqlDriver
  • Sqlite2Driver
  • SqliteDriver
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  */
 11: 
 12: namespace Nette\Database\Drivers;
 13: 
 14: use Nette;
 15: 
 16: 
 17: 
 18: /**
 19:  * Supplemental MS SQL database driver.
 20:  *
 21:  * @author     David Grudl
 22:  */
 23: class MsSqlDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
 24: {
 25:     /** @var Nette\Database\Connection */
 26:     private $connection;
 27: 
 28: 
 29: 
 30:     public function __construct(Nette\Database\Connection $connection, array $options)
 31:     {
 32:         $this->connection = $connection;
 33:     }
 34: 
 35: 
 36: 
 37:     /********************* SQL ****************d*g**/
 38: 
 39: 
 40: 
 41:     /**
 42:      * Delimites identifier for use in a SQL statement.
 43:      */
 44:     public function delimite($name)
 45:     {
 46:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 47:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 48:     }
 49: 
 50: 
 51: 
 52:     /**
 53:      * Formats date-time for use in a SQL statement.
 54:      */
 55:     public function formatDateTime(\DateTime $value)
 56:     {
 57:         return $value->format("'Y-m-d H:i:s'");
 58:     }
 59: 
 60: 
 61: 
 62:     /**
 63:      * Encodes string for use in a LIKE statement.
 64:      */
 65:     public function formatLike($value, $pos)
 66:     {
 67:         $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
 68:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 69:     }
 70: 
 71: 
 72: 
 73:     /**
 74:      * Injects LIMIT/OFFSET to the SQL query.
 75:      */
 76:     public function applyLimit(&$sql, $limit, $offset)
 77:     {
 78:         // offset support is missing
 79:         if ($limit >= 0) {
 80:             $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
 81:         }
 82: 
 83:         if ($offset) {
 84:             throw new Nette\NotImplementedException('Offset is not implemented.');
 85:         }
 86:     }
 87: 
 88: 
 89: 
 90:     /**
 91:      * Normalizes result row.
 92:      */
 93:     public function normalizeRow($row, $statement)
 94:     {
 95:         return $row;
 96:     }
 97: 
 98: 
 99: 
100:     /********************* reflection ****************d*g**/
101: 
102: 
103: 
104:     /**
105:      * Returns list of tables.
106:      */
107:     public function getTables()
108:     {
109:         throw new NotImplementedException;
110:     }
111: 
112: 
113: 
114:     /**
115:      * Returns metadata for all columns in a table.
116:      */
117:     public function getColumns($table)
118:     {
119:         throw new NotImplementedException;
120:     }
121: 
122: 
123: 
124:     /**
125:      * Returns metadata for all indexes in a table.
126:      */
127:     public function getIndexes($table)
128:     {
129:         throw new NotImplementedException;
130:     }
131: 
132: 
133: 
134:     /**
135:      * Returns metadata for all foreign keys in a table.
136:      */
137:     public function getForeignKeys($table)
138:     {
139:         throw new NotImplementedException;
140:     }
141: 
142: 
143: 
144:     /**
145:      * @return bool
146:      */
147:     public function isSupported($item)
148:     {
149:         return $item === self::META;
150:     }
151: 
152: }
153: 
Nette Framework 2.0.0 API API documentation generated by ApiGen 2.7.0