ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
MDB2_Driver_Manager_oci8 Class Reference
+ Inheritance diagram for MDB2_Driver_Manager_oci8:
+ Collaboration diagram for MDB2_Driver_Manager_oci8:

Public Member Functions

 createDatabase ($name)
 create a new database More...
 
 dropDatabase ($name)
 drop an existing database More...
 
 _makeAutoincrement ($name, $table, $start=1)
 add an autoincrement sequence + trigger More...
 
 _dropAutoincrement ($table)
 drop an existing autoincrement sequence + trigger More...
 
 _getTemporaryTableQuery ()
 A method to return the required SQL string that fits between CREATE ... More...
 
 createTable ($name, $fields, $options=array())
 create a new table More...
 
 dropTable ($name)
 drop an existing table More...
 
 alterTable ($name, $changes, $check)
 alter an existing table More...
 
 listDatabases ()
 list all databases More...
 
 listUsers ()
 list all users More...
 
 listViews ()
 list all views in the current database More...
 
 listFunctions ()
 list all functions in the current database More...
 
 listTables ()
 list all tables in the current database More...
 
 listTableFields ($table)
 list all fields in a table in the current database More...
 
 listTableIndexes ($table)
 list all indexes in a table More...
 
 listTableConstraints ($table)
 list all constraints in a table More...
 
 createSequence ($seq_name, $start=1)
 create sequence More...
 
 dropSequence ($seq_name)
 drop existing sequence More...
 
 listSequences ()
 list all sequences in the current database More...
 
- Public Member Functions inherited from MDB2_Driver_Manager_Common
 getFieldDeclarationList ($fields)
 Get declaration of a number of field in bulk. More...
 
 _fixSequenceName ($sqn, $check=false)
 Removes any formatting in an sequence name using the 'seqname_format' option. More...
 
 _fixIndexName ($idx)
 Removes any formatting in an index name using the 'idxname_format' option. More...
 
 createDatabase ($database)
 create a new database More...
 
 dropDatabase ($database)
 drop an existing database More...
 
 _getCreateTableQuery ($name, $fields, $options=array())
 Create a basic SQL query for a new table creation. More...
 
 _getTemporaryTableQuery ()
 A method to return the required SQL string that fits between CREATE ... More...
 
 createTable ($name, $fields, $options=array())
 create a new table More...
 
 getTableCreationQuery ($name, $fields, $options=array())
 PATCH: For Testcases Only. More...
 
 dropTable ($name)
 drop an existing table More...
 
 alterTable ($name, $changes, $check)
 alter an existing table More...
 
 listDatabases ()
 list all databases More...
 
 listUsers ()
 list all users More...
 
 listViews ($database=null)
 list all views in the current database More...
 
 listTableViews ($table)
 list the views in the database that reference a given table More...
 
 listTableTriggers ($table=null)
 list all triggers in the database that reference a given table More...
 
 listFunctions ()
 list all functions in the current database More...
 
 listTables ($database=null)
 list all tables in the current database More...
 
 listTableFields ($table)
 list all fields in a table in the current database More...
 
 createIndex ($table, $name, $definition)
 Get the stucture of a field into an array. More...
 
 dropIndex ($table, $name)
 drop existing index More...
 
 listTableIndexes ($table)
 list all indexes in a table More...
 
 createConstraint ($table, $name, $definition)
 create a constraint on a table More...
 
 dropConstraint ($table, $name, $primary=false)
 drop existing constraint More...
 
 listTableConstraints ($table)
 list all constraints in a table More...
 
 createSequence ($seq_name, $start=1)
 create sequence More...
 
 dropSequence ($name)
 drop existing sequence More...
 
 listSequences ($database=null)
 list all sequences in the current database More...
 
- Public Member Functions inherited from MDB2_Module_Common
 __construct ($db_index)
 Constructor. More...
 
 MDB2_Module_Common ($db_index)
 PHP 4 Constructor. More...
 
getDBInstance ()
 Get the instance of MDB2 associated with the module instance. More...
 

Additional Inherited Members

- Data Fields inherited from MDB2_Module_Common
 $db_index
 

Detailed Description

Definition at line 56 of file oci8.php.

Member Function Documentation

◆ _dropAutoincrement()

MDB2_Driver_Manager_oci8::_dropAutoincrement (   $table)

drop an existing autoincrement sequence + trigger

Parameters
string$tablename of the table
Returns
mixed MDB2_OK on success, a MDB2 error on failure private

Definition at line 220 of file oci8.php.

221  {
222  $db =& $this->getDBInstance();
223  if (PEAR::isError($db)) {
224  return $db;
225  }
226 
227  $table = strtoupper($table);
228  $trigger_name = $table . '_AI_PK';
229  $trigger_name_quoted = $db->quote($trigger_name, 'text');
230  $query = 'SELECT trigger_name FROM user_triggers';
231  $query.= ' WHERE trigger_name='.$trigger_name_quoted.' OR trigger_name='.strtoupper($trigger_name_quoted);
232  $trigger = $db->queryOne($query);
233  if (PEAR::isError($trigger)) {
234  return $trigger;
235  }
236 
237  if ($trigger) {
238  $trigger_name = $db->quoteIdentifier($table . '_AI_PK', true);
239  $trigger_sql = 'DROP TRIGGER ' . $trigger_name;
240  $result = $db->exec($trigger_sql);
241  if (PEAR::isError($result)) {
242  return $db->raiseError($result, null, null,
243  'trigger for autoincrement PK could not be dropped', __FUNCTION__);
244  }
245 
246  $result = $this->dropSequence($table);
247  if (PEAR::isError($result)) {
248  return $db->raiseError($result, null, null,
249  'sequence for autoincrement PK could not be dropped', __FUNCTION__);
250  }
251 
252  $index_name = $table . '_AI_PK';
253  $result = $this->dropConstraint($table, $index_name);
254  if (PEAR::isError($result)) {
255  return $db->raiseError($result, null, null,
256  'primary key for autoincrement PK could not be dropped', __FUNCTION__);
257  }
258  }
259 
260  return MDB2_OK;
261  }
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:72
dropSequence($seq_name)
drop existing sequence
Definition: oci8.php:848
$result
dropConstraint($table, $name, $primary=false)
drop existing constraint
Definition: Common.php:770
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ _getTemporaryTableQuery()

MDB2_Driver_Manager_oci8::_getTemporaryTableQuery ( )

A method to return the required SQL string that fits between CREATE ...

TABLE to create the table as a temporary table.

Returns
string The string required to be placed between "CREATE" and "TABLE" to generate a temporary table, if possible.

Definition at line 273 of file oci8.php.

274  {
275  return 'GLOBAL TEMPORARY';
276  }

◆ _makeAutoincrement()

MDB2_Driver_Manager_oci8::_makeAutoincrement (   $name,
  $table,
  $start = 1 
)

add an autoincrement sequence + trigger

Parameters
string$namename of the PK field
string$tablename of the table
string$startstart value for the sequence
Returns
mixed MDB2_OK on success, a MDB2 error on failure private

Definition at line 144 of file oci8.php.

References $query, $result, $start, array, MDB2_Driver_Manager_Common\createConstraint(), createSequence(), MDB2_Module_Common\getDBInstance(), and PEAR\isError().

145  {
146  $db =& $this->getDBInstance();
147  if (PEAR::isError($db)) {
148  return $db;
149  }
150 
151  $table = strtoupper($table);
152  $index_name = $table . '_AI_PK';
153  $definition = array(
154  'primary' => true,
155  'fields' => array($name => true),
156  );
157  $result = $this->createConstraint($table, $index_name, $definition);
158  if (PEAR::isError($result)) {
159  return $db->raiseError($result, null, null,
160  'primary key for autoincrement PK could not be created', __FUNCTION__);
161  }
162 
163  if (is_null($start)) {
164  $db->beginTransaction();
165  $query = 'SELECT MAX(' . $db->quoteIdentifier($name, true) . ') FROM ' . $db->quoteIdentifier($table, true);
166  $start = $this->db->queryOne($query, 'integer');
167  if (PEAR::isError($start)) {
168  return $start;
169  }
170  ++$start;
171  $result = $this->createSequence($table, $start);
172  $db->commit();
173  } else {
174  $result = $this->createSequence($table, $start);
175  }
176  if (PEAR::isError($result)) {
177  return $db->raiseError($result, null, null,
178  'sequence for autoincrement PK could not be created', __FUNCTION__);
179  }
180  $sequence_name = $db->getSequenceName($table);
181  $trigger_name = $db->quoteIdentifier($table . '_AI_PK', true);
182  $table = $db->quoteIdentifier($table, true);
183  $name = $db->quoteIdentifier($name, true);
184  $trigger_sql = '
185 CREATE TRIGGER '.$trigger_name.'
186  BEFORE INSERT
187  ON '.$table.'
188  FOR EACH ROW
189 DECLARE
190  last_Sequence NUMBER;
191  last_InsertID NUMBER;
192 BEGIN
193  SELECT '.$sequence_name.'.NEXTVAL INTO :NEW.'.$name.' FROM DUAL;
194  IF (:NEW.'.$name.' IS NULL OR :NEW.'.$name.' = 0) THEN
195  SELECT '.$sequence_name.'.NEXTVAL INTO :NEW.'.$name.' FROM DUAL;
196  ELSE
197  SELECT NVL(Last_Number, 0) INTO last_Sequence
198  FROM User_Sequences
199  WHERE UPPER(Sequence_Name) = UPPER(\''.$sequence_name.'\');
200  SELECT :NEW.'.$name.' INTO last_InsertID FROM DUAL;
201  WHILE (last_InsertID > last_Sequence) LOOP
202  SELECT '.$sequence_name.'.NEXTVAL INTO last_Sequence FROM DUAL;
203  END LOOP;
204  END IF;
205 END;
206 ';
207  return $db->exec($trigger_sql);
208  }
$result
createConstraint($table, $name, $definition)
create a constraint on a table
Definition: Common.php:736
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
createSequence($seq_name, $start=1)
create sequence
Definition: oci8.php:824
+ Here is the call graph for this function:

◆ alterTable()

MDB2_Driver_Manager_oci8::alterTable (   $name,
  $changes,
  $check 
)

alter an existing table

Parameters
string$namename of the table that is intended to be changed.
array$changesassociative array that contains the details of each type of change that is intended to be performed. The types of changes that are currently supported are defined as follows:

name

New name for the table.

add

Associative array with the names of fields to be added as
 indexes of the array. The value of each entry of the array
 should be set to another associative array with the properties
 of the fields to be added. The properties of the fields should
 be the same as defined by the MDB2 parser.

remove

Associative array with the names of fields to be removed as indexes
 of the array. Currently the values assigned to each entry are ignored.
 An empty array should be used for future compatibility.

rename

Associative array with the names of fields to be renamed as indexes
 of the array. The value of each entry of the array should be set to
 another associative array with the entry named name with the new
 field name and the entry named Declaration that is expected to contain
 the portion of the field declaration already in DBMS specific SQL code
 as it is used in the CREATE TABLE statement.

change

Associative array with the names of the fields to be changed as indexes
 of the array. Keep in mind that if it is intended to change either the
 name of a field and any other properties, the change array entries
 should have the new names of the fields as array indexes.

The value of each entry of the array should be set to another associative
 array with the properties of the fields to that are meant to be changed as
 array entries. These entries should be assigned to the new values of the
 respective properties. The properties of the fields should be the same
 as defined by the MDB2 parser.

Example array( 'name' => 'userlist', 'add' => array( 'quota' => array( 'type' => 'integer', 'unsigned' => 1 ) ), 'remove' => array( 'file_limit' => array(), 'time_limit' => array() ), 'change' => array( 'name' => array( 'length' => '20', 'definition' => array( 'type' => 'text', 'length' => 20, ), ) ), 'rename' => array( 'sex' => array( 'name' => 'gender', 'definition' => array( 'type' => 'text', 'length' => 1, 'default' => 'M', ), ) ) )

Parameters
boolean$checkindicates whether the function should just check if the DBMS driver can perform the requested table alterations if the value is true or actually perform them otherwise. public
Returns
mixed MDB2_OK on success, a MDB2 error on failure

Definition at line 453 of file oci8.php.

454  {
455  $db =& $this->getDBInstance();
456  if (PEAR::isError($db)) {
457  return $db;
458  }
459 
460  foreach ($changes as $change_name => $change) {
461  switch ($change_name) {
462  case 'add':
463  case 'remove':
464  case 'change':
465  case 'name':
466  case 'rename':
467  break;
468  default:
469  return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
470  'change type "'.$change_name.'" not yet supported', __FUNCTION__);
471  }
472  }
473 
474  if ($check) {
475  return MDB2_OK;
476  }
477 
478  $name = $db->quoteIdentifier($name, true);
479 
480  if (!empty($changes['add']) && is_array($changes['add'])) {
481  $fields = array();
482  foreach ($changes['add'] as $field_name => $field) {
483  $fields[] = $db->getDeclaration($field['type'], $field_name, $field);
484  }
485  $result = $db->exec("ALTER TABLE $name ADD (". implode(', ', $fields).')');
486  if (PEAR::isError($result)) {
487  return $result;
488  }
489  }
490 
491  if (!empty($changes['change']) && is_array($changes['change'])) {
492  $fields = array();
493  foreach ($changes['change'] as $field_name => $field) {
494  $fields[] = $field_name. ' ' . $db->getDeclaration($field['definition']['type'], '', $field['definition']);
495  }
496  $result = $db->exec("ALTER TABLE $name MODIFY (". implode(', ', $fields).')');
497  if (PEAR::isError($result)) {
498  return $result;
499  }
500  }
501 
502  if (!empty($changes['rename']) && is_array($changes['rename'])) {
503  foreach ($changes['rename'] as $field_name => $field) {
504  $field_name = $db->quoteIdentifier($field_name, true);
505  //$query = "ALTER TABLE $name RENAME COLUMN $field_name TO ".$db->quoteIdentifier($field['name']);
506  // Disabled case sensitive renaming smeyer
507  $query = "ALTER TABLE $name RENAME COLUMN $field_name TO ".$field['name'];
508  $result = $db->exec($query);
509  if (PEAR::isError($result)) {
510  return $result;
511  }
512  }
513  }
514 
515  if (!empty($changes['remove']) && is_array($changes['remove'])) {
516  $fields = array();
517  foreach ($changes['remove'] as $field_name => $field) {
518  $fields[] = $db->quoteIdentifier($field_name, true);
519  }
520  $result = $db->exec("ALTER TABLE $name DROP COLUMN ". implode(', ', $fields));
521  if (PEAR::isError($result)) {
522  return $result;
523  }
524  }
525 
526  if (!empty($changes['name'])) {
527  $change_name = $db->quoteIdentifier($changes['name'], true);
528  $result = $db->exec("ALTER TABLE $name RENAME TO ".$change_name);
529  if (PEAR::isError($result)) {
530  return $result;
531  }
532  }
533 
534  return MDB2_OK;
535  }
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:72
$result
const MDB2_ERROR_CANNOT_ALTER
Definition: MDB2.php:103
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ createDatabase()

MDB2_Driver_Manager_oci8::createDatabase (   $name)

create a new database

Parameters
object$dbdatabase object that is extended by this class
string$namename of the database that should be created
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 68 of file oci8.php.

References $query, $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_UNSUPPORTED, and MDB2_OK.

69  {
70  $db =& $this->getDBInstance();
71  if (PEAR::isError($db)) {
72  return $db;
73  }
74 
75  if (!$db->options['emulate_database']) {
76  return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
77  'database creation is only supported if the "emulate_database" option is enabled', __FUNCTION__);
78  }
79 
80  $username = $db->options['database_name_prefix'].$name;
81  $password = $db->dsn['password'] ? $db->dsn['password'] : $name;
82  $tablespace = $db->options['default_tablespace']
83  ? ' DEFAULT TABLESPACE '.$db->options['default_tablespace'] : '';
84 
85  $query = 'CREATE USER '.$username.' IDENTIFIED BY '.$password.$tablespace;
86  $result = $db->standaloneQuery($query, null, true);
87  if (PEAR::isError($result)) {
88  return $result;
89  }
90  $query = 'GRANT CREATE SESSION, CREATE TABLE, UNLIMITED TABLESPACE, CREATE SEQUENCE, CREATE TRIGGER TO '.$username;
91  $result = $db->standaloneQuery($query, null, true);
92  if (PEAR::isError($result)) {
93  $query = 'DROP USER '.$username.' CASCADE';
94  $result2 = $db->standaloneQuery($query, null, true);
95  if (PEAR::isError($result2)) {
96  return $db->raiseError($result2, null, null,
97  'could not setup the database user', __FUNCTION__);
98  }
99  return $result;
100  }
101  return MDB2_OK;
102  }
const MDB2_OK(!class_exists('PEAR'))
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these...
Definition: MDB2.php:72
$result
const MDB2_ERROR_UNSUPPORTED
Definition: MDB2.php:78
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ createSequence()

MDB2_Driver_Manager_oci8::createSequence (   $seq_name,
  $start = 1 
)

create sequence

Parameters
object$dbdatabase object that is extended by this class
string$seq_namename of the sequence to be created
string$startstart value of the sequence; default is 1
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 824 of file oci8.php.

Referenced by _makeAutoincrement().

825  {
826  $db =& $this->getDBInstance();
827  if (PEAR::isError($db)) {
828  return $db;
829  }
830 
831  $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
832  $query = "CREATE SEQUENCE $sequence_name START WITH $start INCREMENT BY 1 NOCACHE";
833  $query.= ($start < 1 ? " MINVALUE $start" : '');
834  return $db->exec($query);
835  }
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the caller graph for this function:

◆ createTable()

MDB2_Driver_Manager_oci8::createTable (   $name,
  $fields,
  $options = array() 
)

create a new table

Parameters
string$nameName of the database that should be created
array$fieldsAssociative array that contains the definition of each field of the new table The indexes of the array entries are the names of the fields of the table an the array entry values are associative arrays like those that are meant to be passed with the field definitions to get[Type]Declaration() functions.

Example array(

'id' => array(
    'type' => 'integer',
    'unsigned' => 1
    'notnull' => 1
    'default' => 0
),
'name' => array(
    'type' => 'text',
    'length' => 12
),
'password' => array(
    'type' => 'text',
    'length' => 12
)

);

Parameters
array$optionsAn associative array of table options: array( 'comment' => 'Foo', 'temporary' => true|false, );
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 316 of file oci8.php.

317  {
318  $db =& $this->getDBInstance();
319  if (PEAR::isError($db)) {
320  return $db;
321  }
322  $db->beginNestedTransaction();
323  $result = parent::createTable($name, $fields, $options);
324  if (!PEAR::isError($result)) {
325  foreach ($fields as $field_name => $field) {
326  if (!empty($field['autoincrement'])) {
327  $result = $this->_makeAutoincrement($field_name, $name);
328  }
329  }
330  }
331  $db->completeNestedTransaction();
332  return $result;
333  }
$result
if(!is_array($argv)) $options
_makeAutoincrement($name, $table, $start=1)
add an autoincrement sequence + trigger
Definition: oci8.php:144
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ dropDatabase()

MDB2_Driver_Manager_oci8::dropDatabase (   $name)

drop an existing database

Parameters
object$dbdatabase object that is extended by this class
string$namename of the database that should be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 115 of file oci8.php.

References MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_ERROR_UNSUPPORTED.

116  {
117  $db =& $this->getDBInstance();
118  if (PEAR::isError($db)) {
119  return $db;
120  }
121 
122  if (!$db->options['emulate_database']) {
123  return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
124  'database dropping is only supported if the "emulate_database" option is enabled', __FUNCTION__);
125  }
126 
127  $username = $db->options['database_name_prefix'].$name;
128  return $db->standaloneQuery('DROP USER '.$username.' CASCADE', null, true);
129  }
const MDB2_ERROR_UNSUPPORTED
Definition: MDB2.php:78
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280
+ Here is the call graph for this function:

◆ dropSequence()

MDB2_Driver_Manager_oci8::dropSequence (   $seq_name)

drop existing sequence

Parameters
object$dbdatabase object that is extended by this class
string$seq_namename of the sequence to be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 848 of file oci8.php.

849  {
850  $db =& $this->getDBInstance();
851  if (PEAR::isError($db)) {
852  return $db;
853  }
854 
855  $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
856  return $db->exec("DROP SEQUENCE $sequence_name");
857  }
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ dropTable()

MDB2_Driver_Manager_oci8::dropTable (   $name)

drop an existing table

Parameters
string$namename of the table that should be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 345 of file oci8.php.

346  {
347  $db =& $this->getDBInstance();
348  if (PEAR::isError($db)) {
349  return $db;
350  }
351  $db->beginNestedTransaction();
352  $result = $this->_dropAutoincrement($name);
353  if (!PEAR::isError($result)) {
354  $result = parent::dropTable($name);
355  }
356  $db->completeNestedTransaction();
357  return $result;
358  }
$result
_dropAutoincrement($table)
drop an existing autoincrement sequence + trigger
Definition: oci8.php:220
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listDatabases()

MDB2_Driver_Manager_oci8::listDatabases ( )

list all databases

Returns
mixed array of database names on success, a MDB2 error on failure public

Definition at line 546 of file oci8.php.

547  {
548  $db =& $this->getDBInstance();
549  if (PEAR::isError($db)) {
550  return $db;
551  }
552 
553  if (!$db->options['emulate_database']) {
554  return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
555  'database listing is only supported if the "emulate_database" option is enabled', __FUNCTION__);
556  }
557 
558  if ($db->options['database_name_prefix']) {
559  $query = 'SELECT SUBSTR(username, ';
560  $query.= (strlen($db->options['database_name_prefix'])+1);
561  $query.= ") FROM sys.dba_users WHERE username LIKE '";
562  $query.= $db->options['database_name_prefix']."%'";
563  } else {
564  $query = 'SELECT username FROM sys.dba_users';
565  }
566  $result2 = $db->standaloneQuery($query, array('text'), false);
567  if (PEAR::isError($result2)) {
568  return $result2;
569  }
570  $result = $result2->fetchCol();
571  if (PEAR::isError($result)) {
572  return $result;
573  }
574  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
575  && $db->options['field_case'] == CASE_LOWER
576  ) {
577  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
578  }
579  $result2->free();
580  return $result;
581  }
$result
const MDB2_ERROR_UNSUPPORTED
Definition: MDB2.php:78
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listFunctions()

MDB2_Driver_Manager_oci8::listFunctions ( )

list all functions in the current database

Returns
mixed array of function names on success, a MDB2 error on failure public

Definition at line 648 of file oci8.php.

649  {
650  $db =& $this->getDBInstance();
651  if (PEAR::isError($db)) {
652  return $db;
653  }
654 
655  $query = "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
656  $result = $db->queryCol($query);
657  if (PEAR::isError($result)) {
658  return $result;
659  }
660  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
661  && $db->options['field_case'] == CASE_LOWER
662  ) {
663  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
664  }
665  return $result;
666  }
$result
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listSequences()

MDB2_Driver_Manager_oci8::listSequences ( )

list all sequences in the current database

Returns
mixed array of sequence names on success, a MDB2 error on failure public

Definition at line 868 of file oci8.php.

869  {
870  $db =& $this->getDBInstance();
871  if (PEAR::isError($db)) {
872  return $db;
873  }
874 
875  $query = "SELECT sequence_name FROM sys.user_sequences";
876  $table_names = $db->queryCol($query);
877  if (PEAR::isError($table_names)) {
878  return $table_names;
879  }
880  $result = array();
881  foreach ($table_names as $table_name) {
882  $result[] = $this->_fixSequenceName($table_name);
883  }
884  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
885  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
886  }
887  return $result;
888  }
$result
_fixSequenceName($sqn, $check=false)
Removes any formatting in an sequence name using the &#39;seqname_format&#39; option.
Definition: Common.php:116
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listTableConstraints()

MDB2_Driver_Manager_oci8::listTableConstraints (   $table)

list all constraints in a table

Parameters
string$tablename of table that should be used in method
Returns
mixed array of constraint names on success, a MDB2 error on failure public

Definition at line 781 of file oci8.php.

782  {
783  $db =& $this->getDBInstance();
784  if (PEAR::isError($db)) {
785  return $db;
786  }
787 
788  $table = $db->quote($table, 'text');
789  $query = 'SELECT constraint_name name FROM user_constraints';
790  $query.= ' WHERE table_name='.$table.' OR table_name='.strtoupper($table);
791  $constraints = $db->queryCol($query);
792  if (PEAR::isError($constraints)) {
793  return $constraints;
794  }
795 
796  $result = array();
797  foreach ($constraints as $constraint) {
798  $constraint = $this->_fixIndexName($constraint);
799  if (!empty($constraint)) {
800  $result[$constraint] = true;
801  }
802  }
803 
804  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
805  && $db->options['field_case'] == CASE_LOWER
806  ) {
807  $result = array_change_key_case($result, $db->options['field_case']);
808  }
809  return array_keys($result);
810  }
$result
Create styles array
The data for the language used.
_fixIndexName($idx)
Removes any formatting in an index name using the &#39;idxname_format&#39; option.
Definition: Common.php:144
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listTableFields()

MDB2_Driver_Manager_oci8::listTableFields (   $table)

list all fields in a table in the current database

Parameters
string$tablename of table that should be used in method
Returns
mixed array of field names on success, a MDB2 error on failure public

Definition at line 707 of file oci8.php.

708  {
709  $db =& $this->getDBInstance();
710  if (PEAR::isError($db)) {
711  return $db;
712  }
713 
714  $table = $db->quote($table, 'text');
715  $query = 'SELECT column_name FROM user_tab_columns';
716  $query.= ' WHERE table_name='.$table.' OR table_name='.strtoupper($table).' ORDER BY column_id';
717  $result = $db->queryCol($query);
718  if (PEAR::isError($result)) {
719  return $result;
720  }
721  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
722  && $db->options['field_case'] == CASE_LOWER
723  ) {
724  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
725  }
726  return $result;
727  }
$result
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listTableIndexes()

MDB2_Driver_Manager_oci8::listTableIndexes (   $table)

list all indexes in a table

Parameters
string$tablename of table that should be used in method
Returns
mixed array of index names on success, a MDB2 error on failure public

Definition at line 739 of file oci8.php.

740  {
741  $db =& $this->getDBInstance();
742  if (PEAR::isError($db)) {
743  return $db;
744  }
745 
746  $table = $db->quote($table, 'text');
747  $query = 'SELECT index_name name FROM user_indexes';
748  $query.= ' WHERE (table_name='.$table.' OR table_name='.strtoupper($table);
749  $query.= ') AND generated=' .$db->quote('N', 'text');
750  $indexes = $db->queryCol($query, 'text');
751  if (PEAR::isError($indexes)) {
752  return $indexes;
753  }
754 
755  $result = array();
756  foreach ($indexes as $index) {
757  $index = $this->_fixIndexName($index);
758  if (!empty($index)) {
759  $result[$index] = true;
760  }
761  }
762 
763  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
764  && $db->options['field_case'] == CASE_LOWER
765  ) {
766  $result = array_change_key_case($result, $db->options['field_case']);
767  }
768  return array_keys($result);
769  }
$result
Create styles array
The data for the language used.
_fixIndexName($idx)
Removes any formatting in an index name using the &#39;idxname_format&#39; option.
Definition: Common.php:144
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listTables()

MDB2_Driver_Manager_oci8::listTables ( )

list all tables in the current database

Returns
mixed array of table names on success, a MDB2 error on failure public

Definition at line 677 of file oci8.php.

678  {
679  $db =& $this->getDBInstance();
680  if (PEAR::isError($db)) {
681  return $db;
682  }
683 
684  $query = 'SELECT table_name FROM sys.user_tables';
685  $result = $db->queryCol($query);
686  if (PEAR::isError($result)) {
687  return $result;
688  }
689  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
690  && $db->options['field_case'] == CASE_LOWER
691  ) {
692  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
693  }
694  return $result;
695  }
$result
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listUsers()

MDB2_Driver_Manager_oci8::listUsers ( )

list all users

Returns
mixed array of user names on success, a MDB2 error on failure public

Definition at line 592 of file oci8.php.

593  {
594  $db =& $this->getDBInstance();
595  if (PEAR::isError($db)) {
596  return $db;
597  }
598 
599  if ($db->options['emulate_database'] && $db->options['database_name_prefix']) {
600  $query = 'SELECT SUBSTR(username, ';
601  $query.= (strlen($db->options['database_name_prefix'])+1);
602  $query.= ") FROM sys.dba_users WHERE username NOT LIKE '";
603  $query.= $db->options['database_name_prefix']."%'";
604  } else {
605  $query = 'SELECT username FROM sys.dba_users';
606  }
607  return $db->queryCol($query);
608  }
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

◆ listViews()

MDB2_Driver_Manager_oci8::listViews ( )

list all views in the current database

Returns
mixed array of view names on success, a MDB2 error on failure public

Definition at line 619 of file oci8.php.

620  {
621  $db =& $this->getDBInstance();
622  if (PEAR::isError($db)) {
623  return $db;
624  }
625 
626  $query = 'SELECT view_name FROM sys.user_views';
627  $result = $db->queryCol($query);
628  if (PEAR::isError($result)) {
629  return $result;
630  }
631  if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
632  && $db->options['field_case'] == CASE_LOWER
633  ) {
634  $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
635  }
636  return $result;
637  }
$result
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
Definition: MDB2.php:163
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:280

The documentation for this class was generated from the following file: