Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

Classes

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