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