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
  • Deprecated
  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:  * Supplemental MS SQL database driver.
 19:  *
 20:  * @author     David Grudl
 21:  */
 22: class MsSqlDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
 23: {
 24:     /** @var Nette\Database\Connection */
 25:     private $connection;
 26: 
 27: 
 28:     public function __construct(Nette\Database\Connection $connection, array $options)
 29:     {
 30:         $this->connection = $connection;
 31:     }
 32: 
 33: 
 34:     /********************* SQL ****************d*g**/
 35: 
 36: 
 37:     /**
 38:      * Delimites identifier for use in a SQL statement.
 39:      */
 40:     public function delimite($name)
 41:     {
 42:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 43:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 44:     }
 45: 
 46: 
 47:     /**
 48:      * Formats boolean for use in a SQL statement.
 49:      */
 50:     public function formatBool($value)
 51:     {
 52:         return $value ? '1' : '0';
 53:     }
 54: 
 55: 
 56:     /**
 57:      * Formats date-time for use in a SQL statement.
 58:      */
 59:     public function formatDateTime(\DateTime $value)
 60:     {
 61:         return $value->format("'Y-m-d H:i:s'");
 62:     }
 63: 
 64: 
 65:     /**
 66:      * Encodes string for use in a LIKE statement.
 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:      * Injects LIMIT/OFFSET to the SQL query.
 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:      * Normalizes result row.
 92:      */
 93:     public function normalizeRow($row, $statement)
 94:     {
 95:         return $row;
 96:     }
 97: 
 98: 
 99:     /********************* reflection ****************d*g**/
100: 
101: 
102:     /**
103:      * Returns list of tables.
104:      */
105:     public function getTables()
106:     {
107:         throw new Nette\NotImplementedException;
108:     }
109: 
110: 
111:     /**
112:      * Returns metadata for all columns in a table.
113:      */
114:     public function getColumns($table)
115:     {
116:         throw new Nette\NotImplementedException;
117:     }
118: 
119: 
120:     /**
121:      * Returns metadata for all indexes in a table.
122:      */
123:     public function getIndexes($table)
124:     {
125:         throw new Nette\NotImplementedException;
126:     }
127: 
128: 
129:     /**
130:      * Returns metadata for all foreign keys in a table.
131:      */
132:     public function getForeignKeys($table)
133:     {
134:         throw new Nette\NotImplementedException;
135:     }
136: 
137: 
138:     /**
139:      * @return bool
140:      */
141:     public function isSupported($item)
142:     {
143:         return $item === self::SUPPORT_COLUMNS_META;
144:     }
145: 
146: }
147: 
Nette Framework 2.0.11 API API documentation generated by ApiGen 2.8.0