Definition at line 58 of file mysql.php.
◆ getTableConstraintDefinition()
MDB2_Driver_Reverse_mysql::getTableConstraintDefinition |
( |
|
$table, |
|
|
|
$index_name |
|
) |
| |
Get the structure of a constraint into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $index_name | name of index that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 241 of file mysql.php.
References $query, $result, $row, $table, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, MDB2_FETCHMODE_ASSOC, and MDB2_PORTABILITY_FIX_CASE.
249 $query =
"SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
250 if (strtolower($index_name) !=
'primary') {
251 $index_name_mdb2 = $db->getIndexName($index_name);
252 $result = $db->queryRow(sprintf(
$query, $db->quote($index_name_mdb2)));
256 $index_name = $index_name_mdb2;
259 $result = $db->query(sprintf(
$query, $db->quote($index_name)));
264 $definition =
array();
266 $row = array_change_key_case(
$row, CASE_LOWER);
267 $key_name =
$row[
'key_name'];
269 if ($db->options[
'field_case'] == CASE_LOWER) {
270 $key_name = strtolower($key_name);
272 $key_name = strtoupper($key_name);
275 if ($index_name == $key_name) {
276 if (
$row[
'non_unique']) {
278 'it was not specified an existing table constraint', __FUNCTION__);
280 if (
$row[
'key_name'] ==
'PRIMARY') {
281 $definition[
'primary'] =
true;
283 $definition[
'unique'] =
true;
285 $column_name =
$row[
'column_name'];
287 if ($db->options[
'field_case'] == CASE_LOWER) {
288 $column_name = strtolower($column_name);
290 $column_name = strtoupper($column_name);
293 $definition[
'fields'][$column_name] =
array(
294 'position' => $colpos++
296 if (!empty(
$row[
'collation'])) {
297 $definition[
'fields'][$column_name][
'sorting'] = (
$row[
'collation'] ==
'A' 298 ?
'ascending' :
'descending');
303 if (empty($definition[
'fields'])) {
305 'it was not specified an existing table constraint', __FUNCTION__);
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTableFieldDefinition()
MDB2_Driver_Reverse_mysql::getTableFieldDefinition |
( |
|
$table, |
|
|
|
$field_name |
|
) |
| |
Get the structure of a field into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $field_name | name of field that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 70 of file mysql.php.
References $column, $columns, $key, $query, $result, $table, $type, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, MDB2_FETCHMODE_ASSOC, and MDB2_PORTABILITY_FIX_CASE.
77 $result = $db->loadModule(
'Datatype', null,
true);
82 $query =
"SHOW COLUMNS FROM $table LIKE ".$db->quote($field_name);
88 $column = array_change_key_case($column, CASE_LOWER);
89 $column[
'name'] = $column[
'field'];
90 unset($column[
'field']);
92 if ($db->options[
'field_case'] == CASE_LOWER) {
93 $column[
'name'] = strtolower($column[
'name']);
95 $column[
'name'] = strtoupper($column[
'name']);
98 $column = array_change_key_case($column, $db->options[
'field_case']);
100 if ($field_name == $column[
'name']) {
101 $mapped_datatype = $db->datatype->mapNativeDatatype($column);
102 if (PEAR::IsError($mapped_datatype)) {
103 return $mapped_datatype;
105 list($types, $length, $unsigned, $fixed) = $mapped_datatype;
107 if (empty($column[
'null']) || $column[
'null'] !==
'YES') {
111 if (array_key_exists(
'default', $column)) {
112 $default = $column[
'default'];
113 if (is_null($default) && $notnull) {
117 $autoincrement =
false;
118 if (!empty($column[
'extra']) && $column[
'extra'] ==
'auto_increment') {
119 $autoincrement =
true;
122 $definition[0] =
array(
123 'notnull' => $notnull,
124 'nativetype' => preg_replace(
'/^([a-z]+)[^a-z].*/i',
'\\1', $column[
'type'])
126 if (!is_null($length)) {
127 $definition[0][
'length'] = $length;
129 if (!is_null($unsigned)) {
130 $definition[0][
'unsigned'] = $unsigned;
132 if (!is_null($fixed)) {
133 $definition[0][
'fixed'] = $fixed;
135 if ($default !==
false) {
136 $definition[0][
'default'] = $default;
138 if ($autoincrement !==
false) {
139 $definition[0][
'autoincrement'] = $autoincrement;
142 $definition[
$key] = $definition[0];
144 unset($definition[
$key][
'default']);
154 'it was not specified an existing table column', __FUNCTION__);
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTableIndexDefinition()
MDB2_Driver_Reverse_mysql::getTableIndexDefinition |
( |
|
$table, |
|
|
|
$constraint_name |
|
) |
| |
Get the structure of an index into an array.
- Parameters
-
string | $table | name of table that should be used in method |
string | $constraint_name | name of constraint that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 168 of file mysql.php.
References $query, $result, $row, $table, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2_ERROR_NOT_FOUND, MDB2_FETCHMODE_ASSOC, and MDB2_PORTABILITY_FIX_CASE.
176 $query =
"SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
177 $constraint_name_mdb2 = $db->getIndexName($constraint_name);
178 $result = $db->queryRow(sprintf(
$query, $db->quote($constraint_name_mdb2)));
182 $constraint_name = $constraint_name_mdb2;
184 $result = $db->query(sprintf(
$query, $db->quote($constraint_name)));
189 $definition =
array();
191 $row = array_change_key_case(
$row, CASE_LOWER);
192 $key_name =
$row[
'key_name'];
194 if ($db->options[
'field_case'] == CASE_LOWER) {
195 $key_name = strtolower($key_name);
197 $key_name = strtoupper($key_name);
200 if ($constraint_name == $key_name) {
201 if (!
$row[
'non_unique']) {
203 $constraint_name .
' is not an existing table constraint', __FUNCTION__);
205 $column_name =
$row[
'column_name'];
207 if ($db->options[
'field_case'] == CASE_LOWER) {
208 $column_name = strtolower($column_name);
210 $column_name = strtoupper($column_name);
213 $definition[
'fields'][$column_name] =
array(
214 'position' => $colpos++
216 if (!empty(
$row[
'collation'])) {
217 $definition[
'fields'][$column_name][
'sorting'] = (
$row[
'collation'] ==
'A' 218 ?
'ascending' :
'descending');
223 if (empty($definition[
'fields'])) {
225 $constraint_name .
' is not an existing table constraint', __FUNCTION__);
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
const MDB2_ERROR_NOT_FOUND
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
if(empty($password)) $table
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ getTriggerDefinition()
MDB2_Driver_Reverse_mysql::getTriggerDefinition |
( |
|
$trigger | ) |
|
Get the structure of a trigger into an array.
EXPERIMENTAL
WARNING: this function is experimental and may change the returned value at any time until labelled as non-experimental
- Parameters
-
string | $trigger | name of trigger that should be used in method |
- Returns
- mixed data array on success, a MDB2 error on failure public
Definition at line 325 of file mysql.php.
References $def, $query, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), and MDB2_FETCHMODE_ASSOC.
332 $query =
'SELECT trigger_name, 333 event_object_table AS table_name, 334 action_statement AS trigger_body, 335 action_timing AS trigger_type, 336 event_manipulation AS trigger_event 337 FROM information_schema.triggers 338 WHERE trigger_name = '. $db->quote($trigger,
'text');
340 'trigger_name' =>
'text',
341 'table_name' =>
'text',
342 'trigger_body' =>
'text',
343 'trigger_type' =>
'text',
344 'trigger_event' =>
'text',
350 $def[
'trigger_comment'] =
'';
351 $def[
'trigger_enabled'] =
true;
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ tableInfo()
MDB2_Driver_Reverse_mysql::tableInfo |
( |
|
$result, |
|
|
|
$mode = null |
|
) |
| |
Returns information about a table or a result set.
- Parameters
-
object | string | $result | MDB2_result object from a query or a string containing the name of a table. While this also accepts a query result resource identifier, this behavior is deprecated. |
int | $mode | a valid tableInfo mode |
- Returns
- array an associative array with the information requested. A MDB2_Error object on failure.
- See also
- MDB2_Driver_Common::setOption()
Definition at line 373 of file mysql.php.
References $i, $res, $result, array, MDB2_Module_Common\getDBInstance(), PEAR\isError(), MDB2\isResultCommon(), MDB2_ERROR_NEED_MORE_DATA, MDB2_PORTABILITY_FIX_CASE, MDB2_TABLEINFO_ORDER, and MDB2_TABLEINFO_ORDERTABLE.
376 return parent::tableInfo(
$result, $mode);
385 if (!is_resource($resource)) {
387 'Could not generate result resource', __FUNCTION__);
391 if ($db->options[
'field_case'] == CASE_LOWER) {
392 $case_func =
'strtolower';
394 $case_func =
'strtoupper';
397 $case_func =
'strval';
400 $count = @mysql_num_fields($resource);
404 $res[
'num_fields'] = $count;
407 $db->loadModule(
'Datatype', null,
true);
408 for (
$i = 0;
$i < $count;
$i++) {
410 'table' => $case_func(@mysql_field_table($resource,
$i)),
411 'name' => $case_func(@mysql_field_name($resource,
$i)),
412 'type' => @mysql_field_type($resource,
$i),
413 'length' => @mysql_field_len($resource,
$i),
414 'flags' => @mysql_field_flags($resource,
$i),
416 if (
$res[
$i][
'type'] ==
'string') {
417 $res[
$i][
'type'] =
'char';
418 } elseif (
$res[
$i][
'type'] ==
'unknown') {
419 $res[
$i][
'type'] =
'decimal';
421 $mdb2type_info = $db->datatype->mapNativeDatatype(
$res[
$i]);
423 return $mdb2type_info;
425 $res[
$i][
'mdb2type'] = $mdb2type_info[0][0];
const MDB2_TABLEINFO_ORDER
These are constants for the tableInfo-function they are bitwised or'ed.
foreach($_POST as $key=> $value) $res
const MDB2_TABLEINFO_ORDERTABLE
const MDB2_ERROR_NEED_MORE_DATA
isResultCommon($value)
Tell whether a value is a MDB2 result implementing the common interface.
Create styles array
The data for the language used.
& getDBInstance()
Get the instance of MDB2 associated with the module instance.
const MDB2_PORTABILITY_FIX_CASE
Portability: convert names of tables and fields to case defined in the "field_case" option when using...
isError($data, $code=null)
Tell whether a value is a PEAR error.
The documentation for this class was generated from the following file:
- Services/Database/lib/PEAR/MDB2/Driver/Reverse/mysql.php