Namespaces

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

Classes

  • MsSqlDriver
  • MySqlDriver
  • OciDriver
  • OdbcDriver
  • PgSqlDriver
  • Sqlite2Driver
  • SqliteDriver
  • Overview
  • Namespace
  • 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:  */
 11: 
 12: namespace Nette\Database\Drivers;
 13: 
 14: use Nette;
 15: 
 16: 
 17: 
 18: /**
 19:  * Supplemental MS SQL database driver.
 20:  *
 21:  * @author     David Grudl
 22:  */
 23: class MsSqlDriver extends Nette\Object implements Nette\Database\ISupplementalDriver
 24: {
 25:     /** @var array */
 26:     public $supports = array('meta' => TRUE);
 27: 
 28:     /** @var Nette\Database\Connection */
 29:     private $connection;
 30: 
 31: 
 32: 
 33:     public function __construct(Nette\Database\Connection $connection, array $options)
 34:     {
 35:         $this->connection = $connection;
 36:     }
 37: 
 38: 
 39: 
 40:     /********************* SQL ****************d*g**/
 41: 
 42: 
 43: 
 44:     /**
 45:      * Delimites identifier for use in a SQL statement.
 46:      */
 47:     public function delimite($name)
 48:     {
 49:         // @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
 50:         return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
 51:     }
 52: 
 53: 
 54: 
 55:     /**
 56:      * Formats date-time for use in a SQL statement.
 57:      */
 58:     public function formatDateTime(\DateTime $value)
 59:     {
 60:         return $value->format("'Y-m-d H:i:s'");
 61:     }
 62: 
 63: 
 64: 
 65:     /**
 66:      * Encodes string for use in a LIKE statement.
 67:      */
 68:     public function formatLike($value, $pos)
 69:     {
 70:         $value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
 71:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
 72:     }
 73: 
 74: 
 75: 
 76:     /**
 77:      * Injects LIMIT/OFFSET to the SQL query.
 78:      */
 79:     public function applyLimit(&$sql, $limit, $offset)
 80:     {
 81:         // offset support is missing
 82:         if ($limit >= 0) {
 83:             $sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
 84:         }
 85: 
 86:         if ($offset) {
 87:             throw new Nette\NotImplementedException('Offset is not implemented.');
 88:         }
 89:     }
 90: 
 91: 
 92: 
 93:     /**
 94:      * Normalizes result row.
 95:      */
 96:     public function normalizeRow($row, $statement)
 97:     {
 98:         return $row;
 99:     }
100: 
101: }
102: 
Nette Framework 2.0beta1 API API documentation generated by ApiGen 2.3.0