ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 getTableCreationQuery ($name, $fields, $options=array())
 PATCH: For Testcases Only. 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...
 
 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 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 329 of file mysqli.php.

330 {
331 $db =& $this->getDBInstance();
332 if (PEAR::isError($db)) {
333 return $db;
334 }
335
336 foreach ($changes as $change_name => $change) {
337 switch ($change_name) {
338 case 'add':
339 case 'remove':
340 case 'change':
341 case 'rename':
342 case 'name':
343 break;
344 default:
345 return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
346 'change type "'.$change_name.'" not yet supported', __FUNCTION__);
347 }
348 }
349
350 if ($check) {
351 return MDB2_OK;
352 }
353
354 $query = '';
355 if (!empty($changes['name'])) {
356 $change_name = $db->quoteIdentifier($changes['name'], true);
357 $query .= 'RENAME TO ' . $change_name;
358 }
359
360 if (!empty($changes['add']) && is_array($changes['add'])) {
361 foreach ($changes['add'] as $field_name => $field) {
362 if ($query) {
363 $query.= ', ';
364 }
365 $query.= 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field);
366 }
367 }
368
369 if (!empty($changes['remove']) && is_array($changes['remove'])) {
370 foreach ($changes['remove'] as $field_name => $field) {
371 if ($query) {
372 $query.= ', ';
373 }
374 $field_name = $db->quoteIdentifier($field_name, true);
375 $query.= 'DROP ' . $field_name;
376 }
377 }
378
379 $rename = array();
380 if (!empty($changes['rename']) && is_array($changes['rename'])) {
381 foreach ($changes['rename'] as $field_name => $field) {
382 $rename[$field['name']] = $field_name;
383 }
384 }
385
386 if (!empty($changes['change']) && is_array($changes['change'])) {
387 foreach ($changes['change'] as $field_name => $field) {
388 if ($query) {
389 $query.= ', ';
390 }
391 if (isset($rename[$field_name])) {
392 $old_field_name = $rename[$field_name];
393 unset($rename[$field_name]);
394 } else {
395 $old_field_name = $field_name;
396 }
397 $old_field_name = $db->quoteIdentifier($old_field_name, true);
398 $query.= "CHANGE $old_field_name " . $db->getDeclaration($field['definition']['type'], $field_name, $field['definition']);
399 }
400 }
401
402 if (!empty($rename) && is_array($rename)) {
403 foreach ($rename as $rename_name => $renamed_field) {
404 if ($query) {
405 $query.= ', ';
406 }
407 $field = $changes['rename'][$renamed_field];
408 $renamed_field = $db->quoteIdentifier($renamed_field, true);
409 $query.= 'CHANGE ' . $renamed_field . ' ' . $db->getDeclaration($field['definition']['type'], $field['name'], $field['definition']);
410 }
411 }
412
413 if (!$query) {
414 return MDB2_OK;
415 }
416
417 $name = $db->quoteIdentifier($name, true);
418 return $db->exec("ALTER TABLE $name $query");
419 }
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
const MDB2_ERROR_CANNOT_ALTER
Definition: MDB2.php:103
& 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

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 788 of file mysqli.php.

789 {
790 $db =& $this->getDBInstance();
791 if (PEAR::isError($db)) {
792 return $db;
793 }
794
795 $type = '';
796 $name = $db->quoteIdentifier($db->getIndexName($name), true);
797 if (!empty($definition['primary'])) {
798 $type = 'PRIMARY';
799 $name = 'KEY';
800 } elseif (!empty($definition['unique'])) {
801 $type = 'UNIQUE';
802 }
803 if (empty($type)) {
804 return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
805 'invalid definition, could not create constraint', __FUNCTION__);
806 }
807
808 $table = $db->quoteIdentifier($table, true);
809 $query = "ALTER TABLE $table ADD $type $name";
810 $fields = array();
811 foreach (array_keys($definition['fields']) as $field) {
812 $fields[] = $db->quoteIdentifier($field, true);
813 }
814 $query .= ' ('. implode(', ', $fields) . ')';
815 return $db->exec($query);
816 }
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92

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 669 of file mysqli.php.

670 {
671 $db =& $this->getDBInstance();
672 if (PEAR::isError($db)) {
673 return $db;
674 }
675
676 $table = $db->quoteIdentifier($table, true);
677 $name = $db->quoteIdentifier($db->getIndexName($name), true);
678 $query = "CREATE INDEX $name ON $table";
679 $fields = array();
680 foreach ($definition['fields'] as $field => $fieldinfo) {
681 if (!empty($fieldinfo['length'])) {
682 $fields[] = $db->quoteIdentifier($field, true) . '(' . $fieldinfo['length'] . ')';
683 } else {
684 $fields[] = $db->quoteIdentifier($field, true);
685 }
686 }
687 $query .= ' ('. implode(', ', $fields) . ')';
688 return $db->exec($query);
689 }

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 921 of file mysqli.php.

922 {
923 $db =& $this->getDBInstance();
924 if (PEAR::isError($db)) {
925 return $db;
926 }
927
928 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
929 $seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true);
930
931 $options_strings = array();
932
933 if (!empty($options['comment'])) {
934 $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text');
935 }
936
937 if (!empty($options['charset'])) {
938 $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset'];
939 if (!empty($options['collate'])) {
940 $options_strings['charset'].= ' COLLATE '.$options['collate'];
941 }
942 }
943
944 $type = false;
945 if (!empty($options['type'])) {
946 $type = $options['type'];
947 } elseif ($db->options['default_table_type']) {
948 $type = $db->options['default_table_type'];
949 }
950 if ($type) {
951 $options_strings[] = "ENGINE = $type";
952 }
953
954 if (!empty($options_strings)) {
955 $query.= ' '.implode(' ', $options_strings);
956 }
957
958 $query = "CREATE TABLE $sequence_name ($seqcol_name INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ($seqcol_name))";
959 if (!empty($options_strings)) {
960 $query .= ' '.implode(' ', $options_strings);
961 }
962 $res = $db->exec($query);
963 if (PEAR::isError($res)) {
964 return $res;
965 }
966
967 if ($start == 1) {
968 return MDB2_OK;
969 }
970
971 $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (".($start-1).')';
972 $res = $db->exec($query);
973 if (!PEAR::isError($res)) {
974 return MDB2_OK;
975 }
976
977 // Handle error
978 $result = $db->exec("DROP TABLE $sequence_name");
979 if (PEAR::isError($result)) {
980 return $db->raiseError($result, null, null,
981 'could not drop inconsistent sequence table', __FUNCTION__);
982 }
983
984 return $db->raiseError($res, null, null,
985 'could not create sequence table', __FUNCTION__);
986 }
if(!is_array($argv)) $options

References $options, $query, $res, $result, $start, 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 830 of file mysqli.php.

831 {
832 $db =& $this->getDBInstance();
833 if (PEAR::isError($db)) {
834 return $db;
835 }
836
837 $table = $db->quoteIdentifier($table, true);
838 if ($primary || strtolower($name) == 'primary') {
839 $query = "ALTER TABLE $table DROP PRIMARY KEY";
840 } else {
841 $name = $db->quoteIdentifier($db->getIndexName($name), true);
842 $query = "ALTER TABLE $table DROP INDEX $name";
843 }
844 return $db->exec($query);
845 }

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 702 of file mysqli.php.

703 {
704 $db =& $this->getDBInstance();
705 if (PEAR::isError($db)) {
706 return $db;
707 }
708
709 $table = $db->quoteIdentifier($table, true);
710 $name = $db->quoteIdentifier($db->getIndexName($name), true);
711 return $db->exec("DROP INDEX $name ON $table");
712 }

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 998 of file mysqli.php.

999 {
1000 $db =& $this->getDBInstance();
1001 if (PEAR::isError($db)) {
1002 return $db;
1003 }
1004
1005 $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
1006 return $db->exec("DROP TABLE $sequence_name");
1007 }

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

+ Here is the call graph for this function:

◆ getTableCreationQuery()

MDB2_Driver_Manager_mysqli::getTableCreationQuery (   $name,
  $fields,
  $options = array() 
)

PATCH: For Testcases Only.

Reimplemented from MDB2_Driver_Manager_Common.

Definition at line 195 of file mysqli.php.

195 {
196 $db =& $this->getDBInstance();
197 if (PEAR::isError($db)) {
198 return $db;
199 }
200
201 $query = $this->_getCreateTableQuery($name, $fields, $options);
202 if (PEAR::isError($query)) {
203 return $query;
204 }
205
206 $options_strings = array();
207
208 if (!empty($options['comment'])) {
209 $options_strings['comment'] = 'COMMENT = '.$db->quote($options['comment'], 'text');
210 }
211
212 if (!empty($options['charset'])) {
213 $options_strings['charset'] = 'DEFAULT CHARACTER SET '.$options['charset'];
214 if (!empty($options['collate'])) {
215 $options_strings['charset'].= ' COLLATE '.$options['collate'];
216 }
217 }
218
219 $type = false;
220 if (!empty($options['type'])) {
221 $type = $options['type'];
222 } elseif ($db->options['default_table_type']) {
223 $type = $db->options['default_table_type'];
224 }
225 if ($type) {
226 $options_strings[] = "ENGINE = $type";
227 }
228
229 if (!empty($options_strings)) {
230 $query .= ' '.implode(' ', $options_strings);
231 }
232
233 return $query;
234 }

References $options, $query, MDB2_Driver_Manager_Common\_getCreateTableQuery(), 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 430 of file mysqli.php.

431 {
432 $db =& $this->getDBInstance();
433 if (PEAR::isError($db)) {
434 return $db;
435 }
436
437 $result = $db->queryCol('SHOW DATABASES');
438 if (PEAR::isError($result)) {
439 return $result;
440 }
441 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
442 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
443 }
444 return $result;
445 }
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

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 475 of file mysqli.php.

476 {
477 $db =& $this->getDBInstance();
478 if (PEAR::isError($db)) {
479 return $db;
480 }
481
482 $query = "SELECT name FROM mysql.proc";
483 /*
484 SELECT ROUTINE_NAME
485 FROM INFORMATION_SCHEMA.ROUTINES
486 WHERE ROUTINE_TYPE = 'FUNCTION'
487 */
488 $result = $db->queryCol($query);
489 if (PEAR::isError($result)) {
490 return $result;
491 }
492 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
493 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
494 }
495 return $result;
496 }

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 1019 of file mysqli.php.

1020 {
1021 $db =& $this->getDBInstance();
1022 if (PEAR::isError($db)) {
1023 return $db;
1024 }
1025
1026 $query = "SHOW TABLES";
1027 if (!is_null($database)) {
1028 $query .= " FROM $database";
1029 }
1030 $table_names = $db->queryCol($query);
1031 if (PEAR::isError($table_names)) {
1032 return $table_names;
1033 }
1034
1035 $result = array();
1036 foreach ($table_names as $table_name) {
1037 if ($sqn = $this->_fixSequenceName($table_name, true)) {
1038 $result[] = $sqn;
1039 }
1040 }
1041 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
1042 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
1043 }
1044 return $result;
1045 }
_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 857 of file mysqli.php.

858 {
859 $db =& $this->getDBInstance();
860 if (PEAR::isError($db)) {
861 return $db;
862 }
863
864 $key_name = 'Key_name';
865 $non_unique = 'Non_unique';
866 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
867 if ($db->options['field_case'] == CASE_LOWER) {
868 $key_name = strtolower($key_name);
869 $non_unique = strtolower($non_unique);
870 } else {
871 $key_name = strtoupper($key_name);
872 $non_unique = strtoupper($non_unique);
873 }
874 }
875
876 $table = $db->quoteIdentifier($table, true);
877 $query = "SHOW INDEX FROM $table";
878 $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
879 if (PEAR::isError($indexes)) {
880 return $indexes;
881 }
882
883 $result = array();
884 foreach ($indexes as $index_data) {
885 if (!$index_data[$non_unique]) {
886 if ($index_data[$key_name] !== 'PRIMARY') {
887 $index = $this->_fixIndexName($index_data[$key_name]);
888 } else {
889 $index = 'PRIMARY';
890 }
891 if (!empty($index)) {
892 $result[$index] = true;
893 }
894 }
895 }
896
897 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
898 $result = array_change_key_case($result, $db->options['field_case']);
899 }
900 return array_keys($result);
901 }
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:134
_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 614 of file mysqli.php.

615 {
616 $db =& $this->getDBInstance();
617 if (PEAR::isError($db)) {
618 return $db;
619 }
620
621 $table = $db->quoteIdentifier($table, true);
622 $result = $db->queryCol("SHOW COLUMNS FROM $table");
623 if (PEAR::isError($result)) {
624 return $result;
625 }
626 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
627 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
628 }
629 return $result;
630 }

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 724 of file mysqli.php.

725 {
726 $db =& $this->getDBInstance();
727 if (PEAR::isError($db)) {
728 return $db;
729 }
730
731 $key_name = 'Key_name';
732 $non_unique = 'Non_unique';
733 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
734 if ($db->options['field_case'] == CASE_LOWER) {
735 $key_name = strtolower($key_name);
736 $non_unique = strtolower($non_unique);
737 } else {
738 $key_name = strtoupper($key_name);
739 $non_unique = strtoupper($non_unique);
740 }
741 }
742
743 $table = $db->quoteIdentifier($table, true);
744 $query = "SHOW INDEX FROM $table";
745 $indexes = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
746 if (PEAR::isError($indexes)) {
747 return $indexes;
748 }
749
750 $result = array();
751 foreach ($indexes as $index_data) {
752 if ($index_data[$non_unique] && ($index = $this->_fixIndexName($index_data[$key_name]))) {
753 $result[$index] = true;
754 }
755 }
756
757 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
758 $result = array_change_key_case($result, $db->options['field_case']);
759 }
760 return array_keys($result);
761 }

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 540 of file mysqli.php.

541 {
542 $db =& $this->getDBInstance();
543 if (PEAR::isError($db)) {
544 return $db;
545 }
546
547 $query = "SHOW /*!50002 FULL*/ TABLES";
548 if (!is_null($database)) {
549 $query .= " FROM $database";
550 }
551 $query.= "/*!50002 WHERE Table_type = 'BASE TABLE'*/";
552
553 $table_names = $db->queryAll($query, null, MDB2_FETCHMODE_ORDERED);
554 if (PEAR::isError($table_names)) {
555 return $table_names;
556 }
557
558 $result = array();
559 foreach ($table_names as $table) {
560 if (!$this->_fixSequenceName($table[0], true)) {
561 $result[] = $table[0];
562 }
563 }
564 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
565 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
566 }
567 return $result;
568 }
const MDB2_FETCHMODE_ORDERED
Column data indexed by numbers, ordered from 0 and up.
Definition: MDB2.php:129

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 508 of file mysqli.php.

509 {
510 $db =& $this->getDBInstance();
511 if (PEAR::isError($db)) {
512 return $db;
513 }
514
515 $query = 'SHOW TRIGGERS';
516 if (!is_null($table)) {
517 $table = $db->quote($table, 'text');
518 $query .= " LIKE $table";
519 }
520 $result = $db->queryCol($query);
521 if (PEAR::isError($result)) {
522 return $result;
523 }
524 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
525 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
526 }
527 return $result;
528 }

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 456 of file mysqli.php.

457 {
458 $db =& $this->getDBInstance();
459 if (PEAR::isError($db)) {
460 return $db;
461 }
462
463 return $db->queryCol('SELECT DISTINCT USER FROM mysql.USER');
464 }

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 580 of file mysqli.php.

581 {
582 $db =& $this->getDBInstance();
583 if (PEAR::isError($db)) {
584 return $db;
585 }
586
587 $query = 'SHOW FULL TABLES';
588 if (!is_null($database)) {
589 $query.= " FROM $database";
590 }
591 $query.= " WHERE Table_type = 'VIEW'";
592
593 $result = $db->queryCol($query);
594 if (PEAR::isError($result)) {
595 return $result;
596 }
597
598 if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
599 $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
600 }
601 return $result;
602 }

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: