ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
MDB2_Driver_Manager_mysqli Class Reference
+ Inheritance diagram for MDB2_Driver_Manager_mysqli:
+ Collaboration diagram for MDB2_Driver_Manager_mysqli:

Public Member Functions

 createDatabase ($name)
 create a new database More...
 
 dropDatabase ($name)
 drop an existing database More...
 
 createTable ($name, $fields, $options=array())
 create a new table More...
 
 alterTable ($name, $changes, $check)
 alter an existing table More...
 
 listDatabases ()
 list all databases More...
 
 listUsers ()
 list all users More...
 
 listFunctions ()
 list all functions in the current database More...
 
 listTableTriggers ($table=null)
 list all triggers in the database that reference a given table More...
 
 listTables ($database=null)
 list all tables in the current database More...
 
 listViews ($database=null)
 list all views 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, $options=array())
 create sequence More...
 
 dropSequence ($seq_name)
 drop existing sequence More...
 
 listSequences ($database=null)
 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 ... TABLE to create the table as a temporary table. 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 ($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 57 of file mysqli.php.

Member Function Documentation

◆ alterTable()

MDB2_Driver_Manager_mysqli::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. @access public
Returns
mixed MDB2_OK on success, a MDB2 error on failure

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 284 of file mysqli.php.

285 {
286 $db =& $this->getDBInstance();
287 if (PEAR::isError($db)) {
288 return $db;
289 }
290
291 foreach ($changes as $change_name => $change) {
292 switch ($change_name) {
293 case 'add':
294 case 'remove':
295 case 'change':
296 case 'rename':
297 case 'name':
298 break;
299 default:
300 return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
301 'change type "'.$change_name.'" not yet supported', __FUNCTION__);
302 }
303 }
304
305 if ($check) {
306 return MDB2_OK;
307 }
308
309 $query = '';
310 if (!empty($changes['name'])) {
311 $change_name = $db->quoteIdentifier($changes['name'], true);
312 $query .= 'RENAME TO ' . $change_name;
313 }
314
315 if (!empty($changes['add']) && is_array($changes['add'])) {
316 foreach ($changes['add'] as $field_name => $field) {
317 if ($query) {
318 $query.= ', ';
319 }
320 $query.= 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field);
321 }
322 }
323
324 if (!empty($changes['remove']) && is_array($changes['remove'])) {
325 foreach ($changes['remove'] as $field_name => $field) {
326 if ($query) {
327 $query.= ', ';
328 }
329 $field_name = $db->quoteIdentifier($field_name, true);
330 $query.= 'DROP ' . $field_name;
331 }
332 }
333
334 $rename = array();
335 if (!empty($changes['rename']) && is_array($changes['rename'])) {
336 foreach ($changes['rename'] as $field_name => $field) {
337 $rename[$field['name']] = $field_name;
338 }
339 }
340
341 if (!empty($changes['change']) && is_array($changes['change'])) {
342 foreach ($changes['change'] as $field_name => $field) {
343 if ($query) {
344 $query.= ', ';
345 }
346 if (isset($rename[$field_name])) {
347 $old_field_name = $rename[$field_name];
348 unset($rename[$field_name]);
349 } else {
350 $old_field_name = $field_name;
351 }
352 $old_field_name = $db->quoteIdentifier($old_field_name, true);
353 $query.= "CHANGE $old_field_name " . $db->getDeclaration($field['definition']['type'], $field_name, $field['definition']);
354 }
355 }
356
357 if (!empty($rename) && is_array($rename)) {
358 foreach ($rename as $rename_name => $renamed_field) {
359 if ($query) {
360 $query.= ', ';
361 }
362 $field = $changes['rename'][$renamed_field];
363 $renamed_field = $db->quoteIdentifier($renamed_field, true);
364 $query.= 'CHANGE ' . $renamed_field . ' ' . $db->getDeclaration($field['definition']['type'], $field['name'], $field['definition']);
365 }
366 }
367
368 if (!$query) {
369 return MDB2_OK;
370 }
371
372 $name = $db->quoteIdentifier($name, true);
373 return $db->exec("ALTER TABLE $name $query");
374 }
const MDB2_OK
The method mapErrorCode in each MDB2_dbtype implementation maps native error codes to one of these.
Definition: MDB2.php:67
const MDB2_ERROR_CANNOT_ALTER
Definition: MDB2.php:98
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4206
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279

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

+ Here is the call graph for this function:

◆ createConstraint()

MDB2_Driver_Manager_mysqli::createConstraint (   $table,
  $name,
  $definition 
)

create a constraint on a table

Parameters
string$tablename of the table on which the constraint is to be created
string$namename of the constraint to be created
array$definitionassociative array that defines properties of the constraint to be created. Currently, only one property named FIELDS is supported. This property is also an associative with the names of the constraint fields as array constraints. Each entry of this array is set to another type of associative array that specifies properties of the constraint that are specific to each field.

Example array( 'fields' => array( 'user_name' => array(), 'last_login' => array() ) )

Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 743 of file mysqli.php.

744 {
745 $db =& $this->getDBInstance();
746 if (PEAR::isError($db)) {
747 return $db;
748 }
749
750 $type = '';
751 $name = $db->quoteIdentifier($db->getIndexName($name), true);
752 if (!empty($definition['primary'])) {
753 $type = 'PRIMARY';
754 $name = 'KEY';
755 } elseif (!empty($definition['unique'])) {
756 $type = 'UNIQUE';
757 }
758 if (empty($type)) {
759 return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
760 'invalid definition, could not create constraint', __FUNCTION__);
761 }
762
763 $table = $db->quoteIdentifier($table, true);
764 $query = "ALTER TABLE $table ADD $type $name";
765 $fields = array();
766 foreach (array_keys($definition['fields']) as $field) {
767 $fields[] = $db->quoteIdentifier($field, true);
768 }
769 $query .= ' ('. implode(', ', $fields) . ')';
770 return $db->exec($query);
771 }
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:87

References $query, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_ERROR_NEED_MORE_DATA.

+ Here is the call graph for this function:

◆ createDatabase()

MDB2_Driver_Manager_mysqli::createDatabase (   $name)

create a new database

Parameters
string$namename of the database that should be created
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 70 of file mysqli.php.

71 {
72 $db =& $this->getDBInstance();
73 if (PEAR::isError($db)) {
74 return $db;
75 }
76
77 $name = $db->quoteIdentifier($name, true);
78 $query = "CREATE DATABASE $name";
79 $result = $db->exec($query);
81 return $result;
82 }
83 return MDB2_OK;
84 }
$result

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

+ Here is the call graph for this function:

◆ createIndex()

MDB2_Driver_Manager_mysqli::createIndex (   $table,
  $name,
  $definition 
)

Get the stucture of a field into an array.

Author
Leoncx
Parameters
string$tablename of the table on which the index is to be created
string$namename of the index to be created
array$definitionassociative array that defines properties of the index to be created. Currently, only one property named FIELDS is supported. This property is also an associative with the names of the index fields as array indexes. Each entry of this array is set to another type of associative array that specifies properties of the index that are specific to each field.

Currently, only the sorting property is supported. It should be used to define the sorting direction of the index. It may be set to either ascending or descending.

Not all DBMS support index sorting direction configuration. The DBMS drivers of those that do not support it ignore this property. Use the function supports() to determine whether the DBMS driver can manage indexes.

Example array( 'fields' => array( 'user_name' => array( 'sorting' => 'ascending' 'length' => 10 ), 'last_login' => array() ) )

Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 624 of file mysqli.php.

625 {
626 $db =& $this->getDBInstance();
627 if (PEAR::isError($db)) {
628 return $db;
629 }
630
631 $table = $db->quoteIdentifier($table, true);
632 $name = $db->quoteIdentifier($db->getIndexName($name), true);
633 $query = "CREATE INDEX $name ON $table";
634 $fields = array();
635 foreach ($definition['fields'] as $field => $fieldinfo) {
636 if (!empty($fieldinfo['length'])) {
637 $fields[] = $db->quoteIdentifier($field, true) . '(' . $fieldinfo['length'] . ')';
638 } else {
639 $fields[] = $db->quoteIdentifier($field, true);
640 }
641 }
642 $query .= ' ('. implode(', ', $fields) . ')';
643 return $db->exec($query);
644 }

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

+ Here is the call graph for this function:

◆ createSequence()

MDB2_Driver_Manager_mysqli::createSequence (   $seq_name,
  $start = 1,
  $options = array() 
)

create sequence

Parameters
string$seq_namename of the sequence to be created
string$startstart value of the sequence; default is 1
array$optionsAn associative array of table options: array( 'comment' => 'Foo', 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'type' => 'innodb', );
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Definition at line 876 of file mysqli.php.

877 {
878 $db =& $this->getDBInstance();
879 if (PEAR::isError($db)) {
880 return $db;
881 }
882
883 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
884 $seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true);
885
886 $options_strings = array();
887
888 if (!empty($options['comment'])) {
889 $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text');
890 }
891
892 if (!empty($options['charset'])) {
893 $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset'];
894 if (!empty($options['collate'])) {
895 $options_strings['charset'].= ' COLLATE '.$options['collate'];
896 }
897 }
898
899 $type = false;
900 if (!empty($options['type'])) {
901 $type = $options['type'];
902 } elseif ($db->options['default_table_type']) {
903 $type = $db->options['default_table_type'];
904 }
905 if ($type) {
906 $options_strings[] = "ENGINE = $type";
907 }
908
909 if (!empty($options_strings)) {
910 $query.= ' '.implode(' ', $options_strings);
911 }
912
913 $query = "CREATE TABLE $sequence_name ($seqcol_name INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ($seqcol_name))";
914 if (!empty($options_strings)) {
915 $query .= ' '.implode(' ', $options_strings);
916 }
917 $res = $db->exec($query);
918 if (PEAR::isError($res)) {
919 return $res;
920 }
921
922 if ($start == 1) {
923 return MDB2_OK;
924 }
925
926 $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (".($start-1).')';
927 $res = $db->exec($query);
928 if (!PEAR::isError($res)) {
929 return MDB2_OK;
930 }
931
932 // Handle error
933 $result = $db->exec("DROP TABLE $sequence_name");
934 if (PEAR::isError($result)) {
935 return $db->raiseError($result, null, null,
936 'could not drop inconsistent sequence table', __FUNCTION__);
937 }
938
939 return $db->raiseError($res, null, null,
940 'could not create sequence table', __FUNCTION__);
941 }
if(!is_array($argv)) $options

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

+ Here is the call graph for this function:

◆ createTable()

MDB2_Driver_Manager_mysqli::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. array( 'id' => array( 'type' => 'integer', 'unsigned' => 1 'notnull' => 1 'default' => 0 ), 'name' => array( 'type' => 'text', 'length' => 12 ), 'password' => array( 'type' => 'text', 'length' => 12 ) );
array$optionsAn associative array of table options: array( 'comment' => 'Foo', 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'type' => 'innodb', );
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 150 of file mysqli.php.

151 {
152 $db =& $this->getDBInstance();
153 if (PEAR::isError($db)) {
154 return $db;
155 }
156
157 $query = $this->_getCreateTableQuery($name, $fields, $options);
158 if (PEAR::isError($query)) {
159 return $query;
160 }
161
162 $options_strings = array();
163
164 if (!empty($options['comment'])) {
165 $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text');
166 }
167
168 if (!empty($options['charset'])) {
169 $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset'];
170 if (!empty($options['collate'])) {
171 $options_strings['charset'].= ' COLLATE '.$options['collate'];
172 }
173 }
174
175 $type = false;
176 if (!empty($options['type'])) {
177 $type = $options['type'];
178 } elseif ($db->options['default_table_type']) {
179 $type = $db->options['default_table_type'];
180 }
181 if ($type) {
182 $options_strings[] = "ENGINE = $type";
183 }
184
185 if (!empty($options_strings)) {
186 $query .= ' '.implode(' ', $options_strings);
187 }
188 return $db->exec($query);
189 }
_getCreateTableQuery($name, $fields, $options=array())
Create a basic SQL query for a new table creation.
Definition: Common.php:212

References $options, $query, MDB2_Driver_Manager_Common\_getCreateTableQuery(), MDB2_Module_Common\getDBInstance(), and PEAR\isError().

+ Here is the call graph for this function:

◆ dropConstraint()

MDB2_Driver_Manager_mysqli::dropConstraint (   $table,
  $name,
  $primary = false 
)

drop existing constraint

Parameters
string$tablename of table that should be used in method
string$namename of the constraint to be dropped
string$primaryhint if the constraint is primary
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 785 of file mysqli.php.

786 {
787 $db =& $this->getDBInstance();
788 if (PEAR::isError($db)) {
789 return $db;
790 }
791
792 $table = $db->quoteIdentifier($table, true);
793 if ($primary || strtolower($name) == 'primary') {
794 $query = "ALTER TABLE $table DROP PRIMARY KEY";
795 } else {
796 $name = $db->quoteIdentifier($db->getIndexName($name), true);
797 $query = "ALTER TABLE $table DROP INDEX $name";
798 }
799 return $db->exec($query);
800 }

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

+ Here is the call graph for this function:

◆ dropDatabase()

MDB2_Driver_Manager_mysqli::dropDatabase (   $name)

drop an existing database

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

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 96 of file mysqli.php.

97 {
98 $db =& $this->getDBInstance();
99 if (PEAR::isError($db)) {
100 return $db;
101 }
102
103 $name = $db->quoteIdentifier($name, true);
104 $query = "DROP DATABASE $name";
105 $result = $db->exec($query);
106 if (PEAR::isError($result)) {
107 return $result;
108 }
109 return MDB2_OK;
110 }

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

+ Here is the call graph for this function:

◆ dropIndex()

MDB2_Driver_Manager_mysqli::dropIndex (   $table,
  $name 
)

drop existing index

Parameters
string$tablename of table that should be used in method
string$namename of the index to be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 657 of file mysqli.php.

658 {
659 $db =& $this->getDBInstance();
660 if (PEAR::isError($db)) {
661 return $db;
662 }
663
664 $table = $db->quoteIdentifier($table, true);
665 $name = $db->quoteIdentifier($db->getIndexName($name), true);
666 return $db->exec("DROP INDEX $name ON $table");
667 }

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

+ Here is the call graph for this function:

◆ dropSequence()

MDB2_Driver_Manager_mysqli::dropSequence (   $seq_name)

drop existing sequence

Parameters
string$seq_namename of the sequence to be dropped
Returns
mixed MDB2_OK on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 953 of file mysqli.php.

954 {
955 $db =& $this->getDBInstance();
956 if (PEAR::isError($db)) {
957 return $db;
958 }
959
960 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
961 return $db->exec("DROP TABLE $sequence_name");
962 }

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

+ Here is the call graph for this function:

◆ listDatabases()

MDB2_Driver_Manager_mysqli::listDatabases ( )

list all databases

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

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 385 of file mysqli.php.

386 {
387 $db =& $this->getDBInstance();
388 if (PEAR::isError($db)) {
389 return $db;
390 }
391
392 $result = $db->queryCol('SHOW DATABASES');
393 if (PEAR::isError($result)) {
394 return $result;
395 }
396 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
397 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
398 }
399 return $result;
400 }
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:158

References $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listFunctions()

MDB2_Driver_Manager_mysqli::listFunctions ( )

list all functions in the current database

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

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 430 of file mysqli.php.

431 {
432 $db =& $this->getDBInstance();
433 if (PEAR::isError($db)) {
434 return $db;
435 }
436
437 $query = "SELECT name FROM mysql.proc";
438 /*
439 SELECT ROUTINE_NAME
440 FROM INFORMATION_SCHEMA.ROUTINES
441 WHERE ROUTINE_TYPE = 'FUNCTION'
442 */
443 $result = $db->queryCol($query);
444 if (PEAR::isError($result)) {
445 return $result;
446 }
447 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
448 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
449 }
450 return $result;
451 }

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

+ Here is the call graph for this function:

◆ listSequences()

MDB2_Driver_Manager_mysqli::listSequences (   $database = null)

list all sequences in the current database

Parameters
stringdatabase, the current is default
Returns
mixed array of sequence names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 974 of file mysqli.php.

975 {
976 $db =& $this->getDBInstance();
977 if (PEAR::isError($db)) {
978 return $db;
979 }
980
981 $query = "SHOW TABLES";
982 if (!is_null($database)) {
983 $query .= " FROM $database";
984 }
985 $table_names = $db->queryCol($query);
986 if (PEAR::isError($table_names)) {
987 return $table_names;
988 }
989
990 $result = array();
991 foreach ($table_names as $table_name) {
992 if ($sqn = $this->_fixSequenceName($table_name, true)) {
993 $result[] = $sqn;
994 }
995 }
996 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
997 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
998 }
999 return $result;
1000 }
_fixSequenceName($sqn, $check=false)
Removes any formatting in an sequence name using the 'seqname_format' option.
Definition: Common.php:116

References $query, $result, MDB2_Driver_Manager_Common\_fixSequenceName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableConstraints()

MDB2_Driver_Manager_mysqli::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 @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 812 of file mysqli.php.

813 {
814 $db =& $this->getDBInstance();
815 if (PEAR::isError($db)) {
816 return $db;
817 }
818
819 $key_name = 'Key_name';
820 $non_unique = 'Non_unique';
821 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
822 if ($db->options['field_case'] == CASE_LOWER) {
823 $key_name = strtolower($key_name);
824 $non_unique = strtolower($non_unique);
825 } else {
826 $key_name = strtoupper($key_name);
827 $non_unique = strtoupper($non_unique);
828 }
829 }
830
831 $table = $db->quoteIdentifier($table, true);
832 $query = "SHOW INDEX FROM $table";
833 $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
834 if (PEAR::isError($indexes)) {
835 return $indexes;
836 }
837
838 $result = array();
839 foreach ($indexes as $index_data) {
840 if (!$index_data[$non_unique]) {
841 if ($index_data[$key_name] !== 'PRIMARY') {
842 $index = $this->_fixIndexName($index_data[$key_name]);
843 } else {
844 $index = 'PRIMARY';
845 }
846 if (!empty($index)) {
847 $result[$index] = true;
848 }
849 }
850 }
851
852 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
853 $result = array_change_key_case($result, $db->options['field_case']);
854 }
855 return array_keys($result);
856 }
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:129
_fixIndexName($idx)
Removes any formatting in an index name using the 'idxname_format' option.
Definition: Common.php:144

References $query, $result, MDB2_Driver_Manager_Common\_fixIndexName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_FETCHMODE_ASSOC, and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableFields()

MDB2_Driver_Manager_mysqli::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 @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 569 of file mysqli.php.

570 {
571 $db =& $this->getDBInstance();
572 if (PEAR::isError($db)) {
573 return $db;
574 }
575
576 $table = $db->quoteIdentifier($table, true);
577 $result = $db->queryCol("SHOW COLUMNS FROM $table");
578 if (PEAR::isError($result)) {
579 return $result;
580 }
581 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
582 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
583 }
584 return $result;
585 }

References $result, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableIndexes()

MDB2_Driver_Manager_mysqli::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 @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 679 of file mysqli.php.

680 {
681 $db =& $this->getDBInstance();
682 if (PEAR::isError($db)) {
683 return $db;
684 }
685
686 $key_name = 'Key_name';
687 $non_unique = 'Non_unique';
688 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
689 if ($db->options['field_case'] == CASE_LOWER) {
690 $key_name = strtolower($key_name);
691 $non_unique = strtolower($non_unique);
692 } else {
693 $key_name = strtoupper($key_name);
694 $non_unique = strtoupper($non_unique);
695 }
696 }
697
698 $table = $db->quoteIdentifier($table, true);
699 $query = "SHOW INDEX FROM $table";
700 $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
701 if (PEAR::isError($indexes)) {
702 return $indexes;
703 }
704
705 $result = array();
706 foreach ($indexes as $index_data) {
707 if ($index_data[$non_unique] && ($index = $this->_fixIndexName($index_data[$key_name]))) {
708 $result[$index] = true;
709 }
710 }
711
712 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
713 $result = array_change_key_case($result, $db->options['field_case']);
714 }
715 return array_keys($result);
716 }

References $query, $result, MDB2_Driver_Manager_Common\_fixIndexName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_FETCHMODE_ASSOC, and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTables()

MDB2_Driver_Manager_mysqli::listTables (   $database = null)

list all tables in the current database

Parameters
stringdatabase, the current is default
Returns
mixed array of table names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 495 of file mysqli.php.

496 {
497 $db =& $this->getDBInstance();
498 if (PEAR::isError($db)) {
499 return $db;
500 }
501
502 $query = "SHOW /*!50002 FULL*/ TABLES";
503 if (!is_null($database)) {
504 $query .= " FROM $database";
505 }
506 $query.= "/*!50002 WHERE Table_type = 'BASE TABLE'*/";
507
508 $table_names = $db->queryAll($query, null, MDB2_FETCHMODE_ORDERED);
509 if (PEAR::isError($table_names)) {
510 return $table_names;
511 }
512
513 $result = array();
514 foreach ($table_names as $table) {
515 if (!$this->_fixSequenceName($table[0], true)) {
516 $result[] = $table[0];
517 }
518 }
519 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
520 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
521 }
522 return $result;
523 }
const MDB2_FETCHMODE_ORDERED
Column data indexed by numbers, ordered from 0 and up.
Definition: MDB2.php:124

References $query, $result, MDB2_Driver_Manager_Common\_fixSequenceName(), MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_FETCHMODE_ORDERED, and MDB2_PORTABILITY_FIX_CASE.

+ Here is the call graph for this function:

◆ listTableTriggers()

MDB2_Driver_Manager_mysqli::listTableTriggers (   $table = null)

list all triggers in the database that reference a given table

Parameters
stringtable for which all referenced triggers should be found
Returns
mixed array of trigger names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 463 of file mysqli.php.

464 {
465 $db =& $this->getDBInstance();
466 if (PEAR::isError($db)) {
467 return $db;
468 }
469
470 $query = 'SHOW TRIGGERS';
471 if (!is_null($table)) {
472 $table = $db->quote($table, 'text');
473 $query .= " LIKE $table";
474 }
475 $result = $db->queryCol($query);
476 if (PEAR::isError($result)) {
477 return $result;
478 }
479 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
480 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
481 }
482 return $result;
483 }

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

+ Here is the call graph for this function:

◆ listUsers()

MDB2_Driver_Manager_mysqli::listUsers ( )

list all users

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

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 411 of file mysqli.php.

412 {
413 $db =& $this->getDBInstance();
414 if (PEAR::isError($db)) {
415 return $db;
416 }
417
418 return $db->queryCol('SELECT DISTINCT USER FROM mysql.USER');
419 }

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

+ Here is the call graph for this function:

◆ listViews()

MDB2_Driver_Manager_mysqli::listViews (   $database = null)

list all views in the current database

Parameters
stringdatabase, the current is default
Returns
mixed array of view names on success, a MDB2 error on failure @access public

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 535 of file mysqli.php.

536 {
537 $db =& $this->getDBInstance();
538 if (PEAR::isError($db)) {
539 return $db;
540 }
541
542 $query = 'SHOW FULL TABLES';
543 if (!is_null($database)) {
544 $query.= " FROM $database";
545 }
546 $query.= " WHERE Table_type = 'VIEW'";
547
548 $result = $db->queryCol($query);
549 if (PEAR::isError($result)) {
550 return $result;
551 }
552
553 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
554 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
555 }
556 return $result;
557 }

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

+ Here is the call graph for this function:

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