Source for file Oracle.php
Documentation is available at Oracle.php
* $Id: Oracle.php 1889 2007-06-28 12:11:55Z zYne $
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @version $Revision: 1889 $
* @category Object Relational Mapping
* @link www.phpdoctrine.com
if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) {
if ($this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query.= (strlen($this->conn->getAttribute(['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
$query =
'SELECT username FROM sys.dba_users';
$result2 =
$this->conn->standaloneQuery($query);
$result =
$result2->fetchColumn();
* lists all availible database functions
$query =
"SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
return $this->conn->fetchColumn($query);
* lists all database triggers
* @param string|null$database
* lists all database sequences
* @param string|null$database
$query =
"SELECT sequence_name FROM sys.user_sequences";
$tableNames =
$this->conn->fetchColumn($query);
return array_map(array($this->conn->formatter, 'fixSequenceName'), $tableNames);
* lists table constraints
* @param string $table database table name
$table =
$this->conn->quote($table, 'text');
$query =
'SELECT index_name name FROM user_constraints'
.
' WHERE table_name = ' .
$table .
' OR table_name = ' .
strtoupper($table);
$constraints =
$this->conn->fetchColumn($query);
return array_map(array($this->conn->formatter, 'fixIndexName'), $constraints);
* lists table constraints
* @param string $table database table name
$sql =
"SELECT column_name, data_type, data_length, nullable, data_default, data_scale, data_precision FROM all_tab_columns"
.
" WHERE table_name = '" .
$table .
"' ORDER BY column_name";
$result =
$this->conn->fetchAssoc($sql);
foreach($result as $val) {
$decl =
$this->conn->dataDict->getPortableDeclaration($val);
$descr[$val['column_name']] =
array(
'name' =>
$val['column_name'],
'notnull' => (bool)
($val['nullable'] ===
'N'),
'ntype' =>
$val['data_type'],
'type' =>
$decl['type'][0],
'alltypes' =>
$decl['type'],
'fixed' =>
$decl['fixed'],
'unsigned' =>
$decl['unsigned'],
'default' =>
$val['data_default'],
'length' =>
$val['data_length'],
'precision' =>
$val['data_precision'],
'scale' =>
$val['scale'],
* lists table constraints
* @param string $table database table name
$table =
$this->conn->quote($table, 'text');
$query =
'SELECT index_name name FROM user_indexes'
.
' WHERE table_name = ' .
$table .
' OR table_name = ' .
strtoupper($table)
.
' AND generated = ' .
$this->conn->quote('N', 'text');
$indexes =
$this->conn->fetchColumn($query);
return array_map(array($this->conn->formatter, 'fixIndexName'), $indexes);
* @param string|null$database
$query =
'SELECT table_name FROM sys.user_tables';
return $this->conn->fetchColumn($query);
* @param string $table database table name
* @param string $table database table name
if ($this->conn->options['emulate_database'] && $this->conn->options['database_name_prefix']) {
$query = 'SELECT SUBSTR(username, ';
$query.= (strlen($this->conn->options['database_name_prefix'])+1);
$query.= ") FROM sys.dba_users WHERE username NOT LIKE '";
$query.= $this->conn->options['database_name_prefix']."%'";
$query =
'SELECT username FROM sys.dba_users';
return $this->conn->fetchColumn($query);
* @param string|null$database
$query =
'SELECT view_name FROM sys.user_views';
return $this->conn->fetchColumn($query);