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