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
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

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