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