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
  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: 
 28:     public function __construct(Connection $connection, array $options)
 29:     {
 30:         $this->connection = $connection;
 31:     }
 32: 
 33: 
 34: 
 35:     /********************* SQL ****************d*g**/
 36: 
 37: 
 38: 
 39:     /**
 40:      * Delimites identifier for use in a SQL statement.
 41:      */
 42:     public function delimite($name)
 43:     {
 44:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 45:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 46:     }
 47: 
 48: 
 49: 
 50:     /**
 51:      * Formats date-time for use in a SQL statement.
 52:      */
 53:     public function formatDateTime(DateTime $value)
 54:     {
 55:         return $value->format("'Y-m-d H:i:s'");
 56:     }
 57: 
 58: 
 59: 
 60:     /**
 61:      * Encodes string for use in a LIKE statement.
 62:      */
 63:     public function formatLike($value, $pos)
 64:     {
 65:         $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
 66:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 67:     }
 68: 
 69: 
 70: 
 71:     /**
 72:      * Injects LIMIT/OFFSET to the SQL query.
 73:      */
 74:     public function applyLimit(&$sql, $limit, $offset)
 75:     {
 76:         // offset support is missing
 77:         if ($limit >= 0) {
 78:             $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
 79:         }
 80: 
 81:         if ($offset) {
 82:             throw new NotImplementedException('Offset is not implemented.');
 83:         }
 84:     }
 85: 
 86: 
 87: 
 88:     /**
 89:      * Normalizes result row.
 90:      */
 91:     public function normalizeRow($row, $statement)
 92:     {
 93:         return $row;
 94:     }
 95: 
 96: 
 97: 
 98:     /********************* reflection ****************d*g**/
 99: 
100: 
101: 
102:     /**
103:      * Returns list of tables.
104:      */
105:     public function getTables()
106:     {
107:         throw new NotImplementedException;
108:     }
109: 
110: 
111: 
112:     /**
113:      * Returns metadata for all columns in a table.
114:      */
115:     public function getColumns($table)
116:     {
117:         throw new NotImplementedException;
118:     }
119: 
120: 
121: 
122:     /**
123:      * Returns metadata for all indexes in a table.
124:      */
125:     public function getIndexes($table)
126:     {
127:         throw new NotImplementedException;
128:     }
129: 
130: 
131: 
132:     /**
133:      * Returns metadata for all foreign keys in a table.
134:      */
135:     public function getForeignKeys($table)
136:     {
137:         throw new NotImplementedException;
138:     }
139: 
140: 
141: 
142:     /**
143:      * @return bool
144:      */
145:     public function isSupported($item)
146:     {
147:         return $item === self::META;
148:     }
149: 
150: }
151: 
Nette Framework 2.0.5 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.7.0