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
  • PHP

Classes

  • MsSqlDriver
  • MySqlDriver
  • OciDriver
  • OdbcDriver
  • PgSqlDriver
  • Sqlite2Driver
  • SqliteDriver
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 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 Oracle database driver.
 17:  *
 18:  * @author     David Grudl
 19:  * @package Nette\Database\Drivers
 20:  */
 21: class OciDriver extends Object implements ISupplementalDriver
 22: {
 23:     /** @var Connection */
 24:     private $connection;
 25: 
 26:     /** @var string  Datetime format */
 27:     private $fmtDateTime;
 28: 
 29: 
 30: 
 31:     public function __construct(Connection $connection, array $options)
 32:     {
 33:         $this->connection = $connection;
 34:         $this->fmtDateTime = isset($options['formatDateTime']) ? $options['formatDateTime'] : 'U';
 35:     }
 36: 
 37: 
 38: 
 39:     /********************* SQL ****************d*g**/
 40: 
 41: 
 42: 
 43:     /**
 44:      * Delimites identifier for use in a SQL statement.
 45:      */
 46:     public function delimite($name)
 47:     {
 48:         // @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
 49:         return '"' . str_replace('"', '""', $name) . '"';
 50:     }
 51: 
 52: 
 53: 
 54:     /**
 55:      * Formats boolean for use in a SQL statement.
 56:      */
 57:     public function formatBool($value)
 58:     {
 59:         return $value ? '1' : '0';
 60:     }
 61: 
 62: 
 63: 
 64:     /**
 65:      * Formats date-time for use in a SQL statement.
 66:      */
 67:     public function formatDateTime(DateTime $value)
 68:     {
 69:         return $value->format($this->fmtDateTime);
 70:     }
 71: 
 72: 
 73: 
 74:     /**
 75:      * Encodes string for use in a LIKE statement.
 76:      */
 77:     public function formatLike($value, $pos)
 78:     {
 79:         throw new NotImplementedException;
 80:     }
 81: 
 82: 
 83: 
 84:     /**
 85:      * Injects LIMIT/OFFSET to the SQL query.
 86:      */
 87:     public function applyLimit(&$sql, $limit, $offset)
 88:     {
 89:         if ($offset > 0) {
 90:             // see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
 91:             $sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
 92:                 . ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
 93:                 . ') WHERE "__rnum" > '. (int) $offset;
 94: 
 95:         } elseif ($limit >= 0) {
 96:             $sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
 97:         }
 98:     }
 99: 
100: 
101: 
102:     /**
103:      * Normalizes result row.
104:      */
105:     public function normalizeRow($row, $statement)
106:     {
107:         return $row;
108:     }
109: 
110: 
111: 
112:     /********************* reflection ****************d*g**/
113: 
114: 
115: 
116:     /**
117:      * Returns list of tables.
118:      */
119:     public function getTables()
120:     {
121:         $tables = array();
122:         foreach ($this->connection->query('SELECT * FROM cat') as $row) {
123:             if ($row[1] === 'TABLE' || $row[1] === 'VIEW') {
124:                 $tables[] = array(
125:                     'name' => $row[0],
126:                     'view' => $row[1] === 'VIEW',
127:                 );
128:             }
129:         }
130:         return $tables;
131:     }
132: 
133: 
134: 
135:     /**
136:      * Returns metadata for all columns in a table.
137:      */
138:     public function getColumns($table)
139:     {
140:         throw new NotImplementedException;
141:     }
142: 
143: 
144: 
145:     /**
146:      * Returns metadata for all indexes in a table.
147:      */
148:     public function getIndexes($table)
149:     {
150:         throw new NotImplementedException;
151:     }
152: 
153: 
154: 
155:     /**
156:      * Returns metadata for all foreign keys in a table.
157:      */
158:     public function getForeignKeys($table)
159:     {
160:         throw new NotImplementedException;
161:     }
162: 
163: 
164: 
165:     /**
166:      * @return bool
167:      */
168:     public function isSupported($item)
169:     {
170:         return $item === self::SUPPORT_COLUMNS_META || $item === self::SUPPORT_SEQUENCE;
171:     }
172: 
173: }
174: 
Nette Framework 2.0.7 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.8.0