Packages

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

Classes

  • NMsSqlDriver
  • NMySqlDriver
  • NOciDriver
  • NOdbcDriver
  • NPgSqlDriver
  • NSqlite2Driver
  • NSqliteDriver
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  * @package Nette\Database\Drivers
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Supplemental MS SQL database driver.
 17:  *
 18:  * @author     David Grudl
 19:  * @package Nette\Database\Drivers
 20:  */
 21: class NMsSqlDriver extends NObject implements ISupplementalDriver
 22: {
 23:     /** @var array */
 24:     public $supports = array('meta' => TRUE);
 25: 
 26:     /** @var NConnection */
 27:     private $connection;
 28: 
 29: 
 30: 
 31:     public function __construct(NConnection $connection, array $options)
 32:     {
 33:         $this->connection = $connection;
 34:     }
 35: 
 36: 
 37: 
 38:     /********************* SQL ****************d*g**/
 39: 
 40: 
 41: 
 42:     /**
 43:      * Delimites identifier for use in a SQL statement.
 44:      */
 45:     public function delimite($name)
 46:     {
 47:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 48:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 49:     }
 50: 
 51: 
 52: 
 53:     /**
 54:      * Formats date-time for use in a SQL statement.
 55:      */
 56:     public function formatDateTime(DateTime $value)
 57:     {
 58:         return $value->format("'Y-m-d H:i:s'");
 59:     }
 60: 
 61: 
 62: 
 63:     /**
 64:      * Encodes string for use in a LIKE statement.
 65:      */
 66:     public function formatLike($value, $pos)
 67:     {
 68:         $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
 69:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 70:     }
 71: 
 72: 
 73: 
 74:     /**
 75:      * Injects LIMIT/OFFSET to the SQL query.
 76:      */
 77:     public function applyLimit(&$sql, $limit, $offset)
 78:     {
 79:         // offset support is missing
 80:         if ($limit >= 0) {
 81:             $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
 82:         }
 83: 
 84:         if ($offset) {
 85:             throw new NotImplementedException('Offset is not implemented.');
 86:         }
 87:     }
 88: 
 89: 
 90: 
 91:     /**
 92:      * Normalizes result row.
 93:      */
 94:     public function normalizeRow($row, $statement)
 95:     {
 96:         return $row;
 97:     }
 98: 
 99: }
100: 
Nette Framework 2.0beta1 (for PHP 5.2) API API documentation generated by ApiGen 2.3.0