Namespaces

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