Namespaces

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

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