cvs: pear /MDB manager_mysql.php
| From: | Lukas Smith | Date: | Mon, 26 Aug 2002 13:37:15 +0000 |
| Subject: | cvs: pear /MDB manager_mysql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5981@lists.php.net to get a copy of this message | ||
lsmith Mon Aug 26 09:37:15 2002 EDT
Modified files:
/pear/MDB manager_mysql.php
Log:
xml reverse engineering:
improved detection of boolean fields (boolean is now the primary choice for length 1 integer/text
fields if the field name includes [is|has]
all database, table, field, index und sequence names are now forced to be lower case
Index: pear/MDB/manager_mysql.php
diff -u pear/MDB/manager_mysql.php:1.26 pear/MDB/manager_mysql.php:1.27
--- pear/MDB/manager_mysql.php:1.26 Sun Aug 25 05:08:38 2002
+++ pear/MDB/manager_mysql.php Mon Aug 26 09:37:15 2002
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@dybnet.de> |
// +----------------------------------------------------------------------+
//
-// $Id: manager_mysql.php,v 1.26 2002/08/25 09:08:38 lsmith Exp $
+// $Id: manager_mysql.php,v 1.27 2002/08/26 13:37:15 lsmith Exp $
//
if(!defined('MDB_MANAGER_MYSQL_INCLUDED'))
@@ -570,6 +570,9 @@
$type[0] = 'integer';
if($length == '1') {
$type[1] = 'boolean';
+ if (preg_match('/[is|has]/', $field_name)) {
+ $type = array_reverse($type);
+ }
}
break;
case 'tinytext':
@@ -583,6 +586,9 @@
$type[1] = 'blob';
} elseif($length == '1') {
$type[1] = 'boolean';
+ if (preg_match('/[is|has]/', $field_name)) {
+ $type = array_reverse($type);
+ }
} elseif(strstr($db_type, 'text'))
$type[1] = 'clob';
break;
@@ -668,7 +674,7 @@
$implicit_sequence = array();
$implicit_sequence['on'] = array();
$implicit_sequence['on']['table'] = $table;
- $implicit_sequence['on']['field'] = $field;
+ $implicit_sequence['on']['field'] = $field_name;
$definition[1]['name'] = $table.'_'.$field_name;
$definition[1]['definition'] = $implicit_sequence;
}
@@ -690,7 +696,7 @@
if($is_primary) {
$implicit_index = array();
$implicit_index['unique'] = 1;
- $implicit_index['FIELDS'][$field] = '';
+ $implicit_index['FIELDS'][$field_name] = '';
$definition[2]['name'] = $field_name;
$definition[2]['definition'] = $implicit_index;
}
@@ -832,21 +838,22 @@
return($result);
}
$definition = array();
+ $definition[$index_name] = array();
while (is_array($row = $db->fetchInto($result, DB_FETCHMODE_ASSOC))) {
$key_name = strtolower($row['Key_name']);
if(!strcmp($index_name, $key_name)) {
if(!$row['Non_unique']) {
- $definition['unique'] = 1;
+ $definition[$index_name]['unique'] = 1;
}
- $column_name = $row['Column_name'];
- $definition['FIELDS'][$column_name] = array();
+ $column_name = strtolower($row['Column_name']);
+ $definition[$index_name]['FIELDS'][$column_name] = array();
if(isset($row['Collation'])) {
- $definition['FIELDS'][$column_name]['sorting'] =
($row['Collation'] == 'A' ? 'ascending' : 'descending');
+ $definition[$index_name]['FIELDS'][$column_name]['sorting']
= ($row['Collation'] == 'A' ? 'ascending' : 'descending');
}
}
}
$db->freeResult($result);
- if (!isset($definition['FIELDS'])) {
+ if (!isset($definition[$index_name]['FIELDS'])) {
return $db->raiseError(DB_ERROR_MANAGER, '', '', 'Get table
index definition: it was not specified an existing table index');
}
return ($definition);
@@ -953,7 +960,7 @@
return($table_names);
}
for($i = 0, $j = count($table_names); $i < $j; $i++) {
- if ($sqn = $db->_isSequenceName($table_names[$i])) {
+ if ($sqn = $db->_isSequenceName(strtolower($table_names[$i]))) {
$start = $db->currId($sqn);
if (MDB::isError($start)) {
return ($start);
@@ -964,7 +971,8 @@
$db->warnings[] = 'database does not support getting current
sequence value,the sequence value was incremented';
}
- $definition = array('start' => $start);
+ $definition = array();
+ $definition[$sqn] = array('start' => $start);
return($definition);
}
}