91 if (!is_array($fields) || empty($fields)) {
93 'missing any fields', __FUNCTION__);
95 foreach ($fields as $field_name => $field) {
96 $query = $db->getDeclaration($field[
'type'], $field_name, $field);
102 return implode(
', ', $query_fields);
123 $seq_pattern =
'/^'.preg_replace(
'/%s/',
'([a-z0-9_]+)', $db->options[
'seqname_format']).
'$/i';
124 $seq_name = preg_replace($seq_pattern,
'\\1', $sqn);
125 if ($seq_name && !strcasecmp($sqn, $db->getSequenceName($seq_name))) {
151 $idx_pattern =
'/^'.preg_replace(
'/%s/',
'([a-z0-9_]+)', $db->options[
'idxname_format']).
'$/i';
152 $idx_name = preg_replace($idx_pattern,
'\\1', $idx);
153 if ($idx_name && !strcasecmp($idx, $db->getIndexName($idx_name))) {
177 'method not implemented', __FUNCTION__);
198 'method not implemented', __FUNCTION__);
221 'no valid table name specified', __FUNCTION__);
223 if (empty($fields)) {
225 'no fields specified for table "'.$name.
'"', __FUNCTION__);
229 return $query_fields;
232 $query_fields.=
', PRIMARY KEY ('.implode(
', ', array_keys(
$options[
'primary'])).
')';
235 $name = $db->quoteIdentifier($name,
true);
237 if (!empty(
$options[
'temporary'])) {
240 $result .=
" TABLE $name ($query_fields)";
338 $name = $db->quoteIdentifier($name,
true);
339 return $db->exec(
"DROP TABLE $name");
443 'method not implemented', __FUNCTION__);
463 'method not implementedd', __FUNCTION__);
483 'method not implemented', __FUNCTION__);
506 'method not implemented', __FUNCTION__);
527 'method not implemented', __FUNCTION__);
548 'method not implemented', __FUNCTION__);
568 'method not implemented', __FUNCTION__);
591 'method not implemented', __FUNCTION__);
612 'method not implemented', __FUNCTION__);
657 $table = $db->quoteIdentifier($table,
true);
658 $name = $db->quoteIdentifier($db->getIndexName($name),
true);
659 $query =
"CREATE INDEX $name ON $table";
661 foreach (array_keys($definition[
'fields']) as $field) {
662 $fields[] = $db->quoteIdentifier($field,
true);
664 $query .=
' ('. implode(
', ', $fields) .
')';
686 $name = $db->quoteIdentifier($db->getIndexName($name),
true);
687 return $db->exec(
"DROP INDEX $name");
708 'method not implemented', __FUNCTION__);
742 $table = $db->quoteIdentifier($table,
true);
743 $name = $db->quoteIdentifier($db->getIndexName($name),
true);
744 $query =
"ALTER TABLE $table ADD CONSTRAINT $name";
745 if (!empty($definition[
'primary'])) {
747 } elseif (!empty($definition[
'unique'])) {
751 foreach (array_keys($definition[
'fields']) as $field) {
752 $fields[] = $db->quoteIdentifier($field,
true);
754 $query .=
' ('. implode(
', ', $fields) .
')';
777 $table = $db->quoteIdentifier($table,
true);
778 $name = $db->quoteIdentifier($db->getIndexName($name),
true);
779 return $db->exec(
"ALTER TABLE $table DROP CONSTRAINT $name");
800 'method not implemented', __FUNCTION__);
822 'method not implemented', __FUNCTION__);
843 'method not implemented', __FUNCTION__);
866 'method not implemented', __FUNCTION__);
dropTable($name)
drop an existing table
listFunctions()
list all functions in the current database
const MDB2_ERROR_UNSUPPORTED
_getTemporaryTableQuery()
A method to return the required SQL string that fits between CREATE ...
listUsers()
list all users
getFieldDeclarationList($fields)
Get declaration of a number of field in bulk.
createIndex($table, $name, $definition)
Get the stucture of a field into an array.
dropSequence($name)
drop existing sequence
listSequences($database=null)
list all sequences in the current database
listTableFields($table)
list all fields in a table in the current database
dropDatabase($database)
drop an existing database
createDatabase($database)
create a new database
dropIndex($table, $name)
drop existing index
if(!is_array($argv)) $options
createConstraint($table, $name, $definition)
create a constraint on a table
const MDB2_ERROR_NEED_MORE_DATA
listDatabases()
list all databases
listTableTriggers($table=null)
list all triggers in the database that reference a given table
listTableIndexes($table)
list all indexes in a table
alterTable($name, $changes, $check)
alter an existing table
_fixSequenceName($sqn, $check=false)
Removes any formatting in an sequence name using the 'seqname_format' option.
createSequence($seq_name, $start=1)
create sequence
listViews($database=null)
list all views in the current database
listTableViews($table)
list the views in the database that reference a given table
Create styles array
The data for the language used.
const MDB2_ERROR_CANNOT_CREATE
createTable($name, $fields, $options=array())
create a new table
_fixIndexName($idx)
Removes any formatting in an index name using the 'idxname_format' option.
dropConstraint($table, $name, $primary=false)
drop existing constraint
getTableCreationQuery($name, $fields, $options=array())
PATCH: For Testcases Only.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
listTableConstraints($table)
list all constraints in a table
_getCreateTableQuery($name, $fields, $options=array())
Create a basic SQL query for a new table creation.
listTables($database=null)
list all tables in the current database
isError($data, $code=null)
Tell whether a value is a PEAR error.