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

Classes

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