Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • 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
    • Bridges
      • Nette

Classes

  • MsSqlDriver
  • MySqlDriver
  • OciDriver
  • OdbcDriver
  • PgSqlDriver
  • Sqlite2Driver
  • SqliteDriver
  • SqlsrvDriver
  • Overview
  • Namespace
  • 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:  */
  7: 
  8: namespace Nette\Database\Drivers;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Supplemental MS SQL database driver.
 15:  */
 16: class MsSqlDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
 17: {
 18: 
 19:     public function convertException(\PDOException $e)
 20:     {
 21:         return Nette\Database\DriverException::from($e);
 22:     }
 23: 
 24: 
 25:     /********************* SQL ****************d*g**/
 26: 
 27: 
 28:     /**
 29:      * Delimites identifier for use in a SQL statement.
 30:      */
 31:     public function delimite($name)
 32:     {
 33:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 34:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 35:     }
 36: 
 37: 
 38:     /**
 39:      * Formats boolean for use in a SQL statement.
 40:      */
 41:     public function formatBool($value)
 42:     {
 43:         return $value ? '1' : '0';
 44:     }
 45: 
 46: 
 47:     /**
 48:      * Formats date-time for use in a SQL statement.
 49:      */
 50:     public function formatDateTime(/*\DateTimeInterface*/ $value)
 51:     {
 52:         return $value->format("'Y-m-d H:i:s'");
 53:     }
 54: 
 55: 
 56:     /**
 57:      * Formats date-time interval for use in a SQL statement.
 58:      */
 59:     public function formatDateInterval(\DateInterval $value)
 60:     {
 61:         throw new Nette\NotSupportedException;
 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 = preg_replace('#^\s*(SELECT|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
 82:             if (!$count) {
 83:                 throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');
 84:             }
 85:         }
 86: 
 87:         if ($offset) {
 88:             throw new Nette\NotSupportedException('Offset is not supported by this database.');
 89:         }
 90:     }
 91: 
 92: 
 93:     /**
 94:      * Normalizes result row.
 95:      */
 96:     public function normalizeRow($row)
 97:     {
 98:         return $row;
 99:     }
100: 
101: 
102:     /********************* reflection ****************d*g**/
103: 
104: 
105:     /**
106:      * Returns list of tables.
107:      */
108:     public function getTables()
109:     {
110:         throw new Nette\NotImplementedException;
111:     }
112: 
113: 
114:     /**
115:      * Returns metadata for all columns in a table.
116:      */
117:     public function getColumns($table)
118:     {
119:         throw new Nette\NotImplementedException;
120:     }
121: 
122: 
123:     /**
124:      * Returns metadata for all indexes in a table.
125:      */
126:     public function getIndexes($table)
127:     {
128:         throw new Nette\NotImplementedException;
129:     }
130: 
131: 
132:     /**
133:      * Returns metadata for all foreign keys in a table.
134:      */
135:     public function getForeignKeys($table)
136:     {
137:         throw new Nette\NotImplementedException;
138:     }
139: 
140: 
141:     /**
142:      * Returns associative array of detected types (IReflection::FIELD_*) in result set.
143:      */
144:     public function getColumnTypes(\PDOStatement $statement)
145:     {
146:         return Nette\Database\Helpers::detectTypes($statement);
147:     }
148: 
149: 
150:     /**
151:      * @param  string
152:      * @return bool
153:      */
154:     public function isSupported($item)
155:     {
156:         return $item === self::SUPPORT_SUBSELECT;
157:     }
158: 
159: }
160: 
Nette 2.3.4 API API documentation generated by ApiGen 2.8.0