ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
mysqli.php
Go to the documentation of this file.
1 <?php
2 // +----------------------------------------------------------------------+
3 // | PHP versions 4 and 5 |
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
6 // | Stig. S. Bakken, Lukas Smith |
7 // | All rights reserved. |
8 // +----------------------------------------------------------------------+
9 // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
10 // | API as well as database abstraction for PHP applications. |
11 // | This LICENSE is in the BSD license style. |
12 // | |
13 // | Redistribution and use in source and binary forms, with or without |
14 // | modification, are permitted provided that the following conditions |
15 // | are met: |
16 // | |
17 // | Redistributions of source code must retain the above copyright |
18 // | notice, this list of conditions and the following disclaimer. |
19 // | |
20 // | Redistributions in binary form must reproduce the above copyright |
21 // | notice, this list of conditions and the following disclaimer in the |
22 // | documentation and/or other materials provided with the distribution. |
23 // | |
24 // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
25 // | Lukas Smith nor the names of his contributors may be used to endorse |
26 // | or promote products derived from this software without specific prior|
27 // | written permission. |
28 // | |
29 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
30 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
31 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
32 // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
33 // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
34 // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
35 // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
36 // | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
37 // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
38 // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
39 // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
40 // | POSSIBILITY OF SUCH DAMAGE. |
41 // +----------------------------------------------------------------------+
42 // | Author: Lukas Smith <smith@pooteeweet.org> |
43 // +----------------------------------------------------------------------+
44 //
45 // $Id: mysqli.php,v 1.81 2007/03/04 22:50:16 quipo Exp $
46 //
47 
48 require_once 'MDB2/Driver/Manager/Common.php';
49 
58 {
59 
60  // }}}
61  // {{{ createDatabase()
62 
70  function createDatabase($name)
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);
80  if (PEAR::isError($result)) {
81  return $result;
82  }
83  return MDB2_OK;
84  }
85 
86  // }}}
87  // {{{ dropDatabase()
88 
96  function dropDatabase($name)
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  }
111 
112  // }}}
113  // {{{ createTable()
114 
150  function createTable($name, $fields, $options = array())
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  }
190 
191 
195  public function getTableCreationQuery($name, $fields, $options = array()) {
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  }
235 
236  // }}}
237  // {{{ alterTable()
238 
329  function alterTable($name, $changes, $check)
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  }
420 
421  // }}}
422  // {{{ listDatabases()
423 
430  function listDatabases()
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  }
446 
447  // }}}
448  // {{{ listUsers()
449 
456  function listUsers()
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  }
465 
466  // }}}
467  // {{{ listFunctions()
468 
475  function listFunctions()
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  }
497 
498  // }}}
499  // {{{ listTableTriggers()
500 
508  function listTableTriggers($table = null)
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  }
529 
530  // }}}
531  // {{{ listTables()
532 
540  function listTables($database = null)
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  }
569 
570  // }}}
571  // {{{ listViews()
572 
580  function listViews($database = null)
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  }
603 
604  // }}}
605  // {{{ listTableFields()
606 
614  function listTableFields($table)
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  }
631 
632  // }}}
633  // {{{ createIndex()
634 
669  function createIndex($table, $name, $definition)
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  }
690 
691  // }}}
692  // {{{ dropIndex()
693 
702  function dropIndex($table, $name)
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  }
713 
714  // }}}
715  // {{{ listTableIndexes()
716 
724  function listTableIndexes($table)
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  }
762 
763  // }}}
764  // {{{ createConstraint()
765 
788  function createConstraint($table, $name, $definition)
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  }
817 
818  // }}}
819  // {{{ dropConstraint()
820 
830  function dropConstraint($table, $name, $primary = false)
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  }
846 
847  // }}}
848  // {{{ listTableConstraints()
849 
857  function listTableConstraints($table)
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  }
902 
903  // }}}
904  // {{{ createSequence()
905 
921  function createSequence($seq_name, $start = 1, $options = array())
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  }
987 
988  // }}}
989  // {{{ dropSequence()
990 
998  function dropSequence($seq_name)
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  }
1008 
1009  // }}}
1010  // {{{ listSequences()
1011 
1019  function listSequences($database = null)
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  }
1046 
1047  // }}}
1048 }
1049 ?>
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Definition: MDB2.php:134
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
dropDatabase($name)
drop an existing database
Definition: mysqli.php:96
dropConstraint($table, $name, $primary=false)
drop existing constraint
Definition: mysqli.php:830
$result
createTable($name, $fields, $options=array())
create a new table
Definition: mysqli.php:150
listTableFields($table)
list all fields in a table in the current database
Definition: mysqli.php:614
createDatabase($name)
create a new database
Definition: mysqli.php:70
const MDB2_ERROR_CANNOT_ALTER
Definition: MDB2.php:103
listViews($database=null)
list all views in the current database
Definition: mysqli.php:580
listDatabases()
list all databases
Definition: mysqli.php:430
listTables($database=null)
list all tables in the current database
Definition: mysqli.php:540
listTableIndexes($table)
list all indexes in a table
Definition: mysqli.php:724
const MDB2_FETCHMODE_ORDERED
Column data indexed by numbers, ordered from 0 and up.
Definition: MDB2.php:129
if(!is_array($argv)) $options
alterTable($name, $changes, $check)
alter an existing table
Definition: mysqli.php:329
listSequences($database=null)
list all sequences in the current database
Definition: mysqli.php:1019
listTableConstraints($table)
list all constraints in a table
Definition: mysqli.php:857
const MDB2_ERROR_NEED_MORE_DATA
Definition: MDB2.php:92
createSequence($seq_name, $start=1, $options=array())
create sequence
Definition: mysqli.php:921
_fixSequenceName($sqn, $check=false)
Removes any formatting in an sequence name using the &#39;seqname_format&#39; option.
Definition: Common.php:116
createConstraint($table, $name, $definition)
create a constraint on a table
Definition: mysqli.php:788
dropIndex($table, $name)
drop existing index
Definition: mysqli.php:702
createIndex($table, $name, $definition)
Get the stucture of a field into an array.
Definition: mysqli.php:669
listUsers()
list all users
Definition: mysqli.php:456
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
dropSequence($seq_name)
drop existing sequence
Definition: mysqli.php:998
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
Definition: MDB2.php:4238
listTableTriggers($table=null)
list all triggers in the database that reference a given table
Definition: mysqli.php:508
_getCreateTableQuery($name, $fields, $options=array())
Create a basic SQL query for a new table creation.
Definition: Common.php:212
getTableCreationQuery($name, $fields, $options=array())
PATCH: For Testcases Only.
Definition: mysqli.php:195
listFunctions()
list all functions in the current database
Definition: mysqli.php:475
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