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
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

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 (https://nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://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 implements Nette\Database\ISupplementalDriver
 17: {
 18:     use Nette\SmartObject;
 19: 
 20:     public function convertException(\PDOException $e)
 21:     {
 22:         return Nette\Database\DriverException::from($e);
 23:     }
 24: 
 25: 
 26:     /********************* SQL ****************d*g**/
 27: 
 28: 
 29:     /**
 30:      * Delimites identifier for use in a SQL statement.
 31:      */
 32:     public function delimite($name)
 33:     {
 34:         // @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
 35:         return '[' . str_replace(['[', ']'], ['[[', ']]'], $name) . ']';
 36:     }
 37: 
 38: 
 39:     /**
 40:      * Formats boolean for use in a SQL statement.
 41:      */
 42:     public function formatBool($value)
 43:     {
 44:         return $value ? '1' : '0';
 45:     }
 46: 
 47: 
 48:     /**
 49:      * Formats date-time for use in a SQL statement.
 50:      */
 51:     public function formatDateTime(/*\DateTimeInterface*/ $value)
 52:     {
 53:         return $value->format("'Y-m-d H:i:s'");
 54:     }
 55: 
 56: 
 57:     /**
 58:      * Formats date-time interval for use in a SQL statement.
 59:      */
 60:     public function formatDateInterval(\DateInterval $value)
 61:     {
 62:         throw new Nette\NotSupportedException;
 63:     }
 64: 
 65: 
 66:     /**
 67:      * Encodes string for use in a LIKE statement.
 68:      */
 69:     public function formatLike($value, $pos)
 70:     {
 71:         $value = strtr($value, ["'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]']);
 72:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 73:     }
 74: 
 75: 
 76:     /**
 77:      * Injects LIMIT/OFFSET to the SQL query.
 78:      */
 79:     public function applyLimit(&$sql, $limit, $offset)
 80:     {
 81:         if ($offset) {
 82:             throw new Nette\NotSupportedException('Offset is not supported by this database.');
 83: 
 84:         } elseif ($limit < 0) {
 85:             throw new Nette\InvalidArgumentException('Negative offset or limit.');
 86: 
 87:         } elseif ($limit !== null) {
 88:             $sql = preg_replace('#^\s*(SELECT(\s+DISTINCT|\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
 89:             if (!$count) {
 90:                 throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');
 91:             }
 92:         }
 93:     }
 94: 
 95: 
 96:     /**
 97:      * Normalizes result row.
 98:      */
 99:     public function normalizeRow($row)
100:     {
101:         return $row;
102:     }
103: 
104: 
105:     /********************* reflection ****************d*g**/
106: 
107: 
108:     /**
109:      * Returns list of tables.
110:      */
111:     public function getTables()
112:     {
113:         throw new Nette\NotImplementedException;
114:     }
115: 
116: 
117:     /**
118:      * Returns metadata for all columns in a table.
119:      */
120:     public function getColumns($table)
121:     {
122:         throw new Nette\NotImplementedException;
123:     }
124: 
125: 
126:     /**
127:      * Returns metadata for all indexes in a table.
128:      */
129:     public function getIndexes($table)
130:     {
131:         throw new Nette\NotImplementedException;
132:     }
133: 
134: 
135:     /**
136:      * Returns metadata for all foreign keys in a table.
137:      */
138:     public function getForeignKeys($table)
139:     {
140:         throw new Nette\NotImplementedException;
141:     }
142: 
143: 
144:     /**
145:      * Returns associative array of detected types (IReflection::FIELD_*) in result set.
146:      */
147:     public function getColumnTypes(\PDOStatement $statement)
148:     {
149:         return Nette\Database\Helpers::detectTypes($statement);
150:     }
151: 
152: 
153:     /**
154:      * @param  string
155:      * @return bool
156:      */
157:     public function isSupported($item)
158:     {
159:         return $item === self::SUPPORT_SUBSELECT;
160:     }
161: }
162: 
Nette 2.4-20170829 API API documentation generated by ApiGen 2.8.0