function _demo_get_fields in Demonstration site (Sandbox / Snapshot) 7
Same name and namespace in other branches
- 8 demo.module \_demo_get_fields()
- 5 database_mysql_dump.inc \_demo_get_fields()
- 6 database_mysql_dump.inc \_demo_get_fields()
Return table fields and their properties.
1 call to _demo_get_fields()
- _demo_dump_table_data in ./
database_mysql_dump.inc - Dump table data.
File
- ./
database_mysql_dump.inc, line 295
Code
function _demo_get_fields($result) {
$fields = array();
switch (db_driver()) {
case 'mysql':
$i = 0;
while ($meta = $result
->getColumnMeta($i)) {
settype($meta, 'object');
// pdo_mysql does not add a native type for INT fields.
if (isset($meta->native_type)) {
// Enhance the field definition for mysql-extension compatibilty.
$meta->numeric = strtolower($meta->native_type) == 'short';
$meta->blob = strtolower($meta->native_type) == 'blob';
// Add custom properties.
$meta->timestamp = strtolower($meta->native_type) == 'long';
}
else {
$meta->numeric = $meta->blob = $meta->timestamp = FALSE;
}
$meta->binary = array_search('not_null', $meta->flags);
$fields[] = $meta;
$i++;
}
break;
}
return $fields;
}