Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • Overview
  • Package
  • 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:  * @package Nette\Database\Drivers
  7:  */
  8: 
  9: 
 10: 
 11: /**
 12:  * Supplemental MS SQL database driver.
 13:  *
 14:  * @author     David Grudl
 15:  * @package Nette\Database\Drivers
 16:  */
 17: class NMsSqlDriver extends NObject implements ISupplementalDriver
 18: {
 19: 
 20: 
 21:     /********************* SQL ****************d*g**/
 22: 
 23: 
 24:     /**
 25:      * Delimites identifier for use in a SQL statement.
 26:      */
 27:     public function delimite($name)
 28:     {
 29:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 30:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 31:     }
 32: 
 33: 
 34:     /**
 35:      * Formats boolean for use in a SQL statement.
 36:      */
 37:     public function formatBool($value)
 38:     {
 39:         return $value ? '1' : '0';
 40:     }
 41: 
 42: 
 43:     /**
 44:      * Formats date-time for use in a SQL statement.
 45:      */
 46:     public function formatDateTime(DateTime $value)
 47:     {
 48:         return $value->format("'Y-m-d H:i:s'");
 49:     }
 50: 
 51: 
 52:     /**
 53:      * Encodes string for use in a LIKE statement.
 54:      */
 55:     public function formatLike($value, $pos)
 56:     {
 57:         $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
 58:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 59:     }
 60: 
 61: 
 62:     /**
 63:      * Injects LIMIT/OFFSET to the SQL query.
 64:      */
 65:     public function applyLimit(& $sql, $limit, $offset)
 66:     {
 67:         if ($limit >= 0) {
 68:             $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
 69:         }
 70: 
 71:         if ($offset) {
 72:             throw new NotImplementedException('Offset is not implemented.');
 73:         }
 74:     }
 75: 
 76: 
 77:     /**
 78:      * Normalizes result row.
 79:      */
 80:     public function normalizeRow($row, $statement)
 81:     {
 82:         return $row;
 83:     }
 84: 
 85: 
 86:     /********************* reflection ****************d*g**/
 87: 
 88: 
 89:     /**
 90:      * Returns list of tables.
 91:      */
 92:     public function getTables()
 93:     {
 94:         throw new NotImplementedException;
 95:     }
 96: 
 97: 
 98:     /**
 99:      * Returns metadata for all columns in a table.
100:      */
101:     public function getColumns($table)
102:     {
103:         throw new NotImplementedException;
104:     }
105: 
106: 
107:     /**
108:      * Returns metadata for all indexes in a table.
109:      */
110:     public function getIndexes($table)
111:     {
112:         throw new NotImplementedException;
113:     }
114: 
115: 
116:     /**
117:      * Returns metadata for all foreign keys in a table.
118:      */
119:     public function getForeignKeys($table)
120:     {
121:         throw new NotImplementedException;
122:     }
123: 
124: 
125:     /**
126:      * @return bool
127:      */
128:     public function isSupported($item)
129:     {
130:         return $item === self::SUPPORT_COLUMNS_META;
131:     }
132: 
133: }
134: 
Nette Framework 2.0.18 (for PHP 5.2, prefixed) API documentation generated by ApiGen 2.8.0