cvs: pear /MDB/MDB/Modules/Manager mysql.php
| From: | Lukas Smith | Date: | Tue, 16 Sep 2003 11:14:04 +0000 |
| Subject: | cvs: pear /MDB/MDB/Modules/Manager mysql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-12772@lists.php.net to get a copy of this message | ||
lsmith Tue Sep 16 07:14:04 2003 EDT
Modified files:
/pear/MDB/MDB/Modules/Manager mysql.php
Log:
- renamed _verifyTransactionalTableType to _verifyTableType
- fixed checking of InnoDB table handler
Index: pear/MDB/MDB/Modules/Manager/mysql.php
diff -u pear/MDB/MDB/Modules/Manager/mysql.php:1.55 pear/MDB/MDB/Modules/Manager/mysql.php:1.56
--- pear/MDB/MDB/Modules/Manager/mysql.php:1.55 Wed Sep 3 11:22:52 2003
+++ pear/MDB/MDB/Modules/Manager/mysql.php Tue Sep 16 07:14:04 2003
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: mysql.php,v 1.55 2003/09/03 15:22:52 lsmith Exp $
+// $Id: mysql.php,v 1.56 2003/09/16 11:14:04 lsmith Exp $
//
require_once 'MDB/Modules/Manager/Common.php';
@@ -72,7 +72,7 @@
}
// }}}
- // {{{ _verifyTransactionalTableType()
+ // {{{ _verifyTableType()
/**
* verify that chosen transactional table hanlder is available in the database
@@ -82,19 +82,19 @@
* @return mixed MDB_OK on success, a MDB error on failure
* @access private
*/
- function _verifyTransactionalTableType($table_type)
+ function _verifyTableType($table_type)
{
$db =& $GLOBALS['_MDB_databases'][$this->db_index];
switch(strtoupper($table_type)) {
case 'BERKELEYDB':
case 'BDB':
- $check = 'have_bdb';
+ $check = array('have_bdb');
break;
case 'INNODB':
- $check = 'have_innobase';
+ $check = array('have_innobase', 'have_innodb');
break;
case 'GEMINI':
- $check = 'have_gemini';
+ $check = array('have_gemini');
break;
case 'HEAP':
case 'ISAM':
@@ -107,32 +107,35 @@
return $db->raiseError(MDB_ERROR_UNSUPPORTED, null, null,
$table_type.' is not a supported table type');
}
- if (MDB::isError($connect = $db->connect())) {
- return $connect;
- }
if (isset($this->verified_table_types[$table_type])
- && $this->verified_table_types[$table_type] == $db->connection)
- {
+ && $this->verified_table_types[$table_type] == $db->connection
+ ) {
return MDB_OK;
}
- $result = $db->query("SHOW VARIABLES LIKE '$check'", null, false);
- if (MDB::isError($result)) {
- return $db->mysqlRaiseError();
- }
- $has = $db->fetchAll($result, MDB_FETCHMODE_ORDERED);
- if (MDB::isError($has)) {
- return $has;
+ $not_supported = false;
+ for($i=0, $j=count($check); $i<$j; ++$i) {
+ $result = $db->query('SHOW VARIABLES LIKE
'.$db->getValue('text', $check[$i]), null, false);
+ if (MDB::isError($result)) {
+ return $db->mysqlRaiseError();
+ }
+ $has = $db->fetchRow($result, MDB_FETCHMODE_ORDERED);
+ if (MDB::isError($has)) {
+ return $has;
+ }
+ if (is_array($has)) {
+ $not_supported = true;
+ if ($has[1] == 'YES') {
+ $this->verified_table_types[$table_type] = $db->connection;
+ return MDB_OK;
+ }
+ }
}
- if (count($has) == 0) {
- return $db->raiseError(MDB_ERROR_UNSUPPORTED, null, null,
- 'could not tell if '.$table_type.' is a supported table type');
- }
- if (strcmp($has[0][1], 'YES')) {
+ if ($not_supported) {
return $db->raiseError(MDB_ERROR_UNSUPPORTED, null, null,
$table_type.' is not a supported table type by this MySQL database
server');
}
- $this->verified_table_types[$table_type] = $db->connection;
- return MDB_OK;
+ return $db->raiseError(MDB_ERROR_UNSUPPORTED, null, null,
+ 'could not tell if '.$table_type.' is a supported table type');
}
// }}}
@@ -229,7 +232,7 @@
return $db->raiseError(MDB_ERROR_CANNOT_CREATE, null, null,
'createTable: no fields specified for table
"'.$name.'"');
}
- if (MDB::isError($verify =
$this->_verifyTransactionalTableType($db->default_table_type))) {
+ if (MDB::isError($verify = $this->_verifyTableType($db->default_table_type))) {
return $verify;
}
if (MDB::isError($query_fields = $this->getFieldDeclarationList($fields))) {
@@ -237,8 +240,8 @@
'createTable: unkown error');
}
if (isset($db->supported['transactions'])
- && $db->default_table_type=='BDB')
- {
+ && ($db->default_table_type == 'BDB' || $db->default_table_type
== 'BERKELEYDB')
+ ) {
$query_fields .= ', dummy_primary_key INT NOT NULL AUTO_INCREMENT, PRIMARY KEY
(dummy_primary_key)';
}
$query = "CREATE TABLE $name ($query_fields)".(strlen($db->default_table_type)
? ' TYPE='.$db->default_table_type : '');