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