Packages

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