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

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