cvs: pear /MDB common.php manager_common.php manager_mysql.php
| From: | Lukas Smith | Date: | Fri, 31 May 2002 17:28:25 +0000 |
| Subject: | cvs: pear /MDB common.php manager_common.php manager_mysql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4320@lists.php.net to get a copy of this message | ||
lsmith Fri May 31 13:28:25 2002 EDT
Modified files:
/pear/MDB manager_mysql.php manager_common.php common.php
Log:
switched from setError() to PEAR Error handling in all instances
Index: pear/MDB/manager_mysql.php diff -u pear/MDB/manager_mysql.php:1.1 pear/MDB/manager_mysql.php:1.2 --- pear/MDB/manager_mysql.php:1.1 Thu May 30 10:35:02 2002 +++ pear/MDB/manager_mysql.php Fri May 31 13:28:25 2002 @@ -6,7 +6,7 @@ /* * manager_mysql.php * - * @(#) $Header: /usr/repository/pear/MDB/manager_mysql.php,v 1.1 2002/05/30 14:35:02 lsmith Exp $ + * @(#) $Header: /usr/repository/pear/MDB/manager_mysql.php,v 1.2 2002/05/31 17:28:25 lsmith Exp $ * */ @@ -30,7 +30,7 @@ return $result; } if (!mysql_drop_db($name, $this->connection)) { - return $$db->mysqlRaiseError(DB_ERROR_CANNOT_DROP); + return $db->mysqlRaiseError(DB_ERROR_CANNOT_DROP); } return (1); } @@ -141,14 +141,15 @@ $query .= "CHANGE $old_field_name ".$changes["RenamedFields"][$old_field_name]["Declaration"]; } } - return ($db->Query("ALTER TABLE $name $query")); + return ($db->query("ALTER TABLE $name $query")); } } function listTables(&$db, &$tables) { - if(!$db->queryColumn("SHOW TABLES",$table_names)) { - return(0); + $result = $db->queryColumn("SHOW TABLES", $table_names); + if(MDB::isError($result)) { + return $result; } $prefix_length = strlen($db->sequence_prefix); for($tables = array(), $table = 0; $table < count($table_names); ++$table) @@ -161,16 +162,18 @@ function listTableFields(&$db, $table, &$fields) { - if(!($result=$db->query("SHOW COLUMNS FROM $table"))) { - return(0); + $result = $db->query("SHOW COLUMNS FROM $table"); + if(MDB::isError($result)) { + return $result; } - if(!$db->getColumnNames($result, $columns)) { + $result2 = $db->getColumnNames($result, $columns); + if(MDB::isError($result2)) { $db->freeResult($result); - return(0); + return $result2; } if(!isset($columns["field"])) { $db->freeResult($result); - return($db->setError("List table fields","show columns does not return the table field names")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: show columns does not return the table field names'); } $field_column=$columns["field"]; for($fields=array(), $field = 0; !$db->endOfResult($result); ++$field) { @@ -186,20 +189,22 @@ { $field_name = strtolower($field); if ($field_name == $db->dummy_primary_key) { - return($db->SetError("List table fields",$db->dummy_primary_key." is an hidden column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: '.$db->dummy_primary_key.' is an hidden column'); } - if (!($result=$db->query("SHOW COLUMNS FROM $table"))) { - return(0); + $result = $db->query("SHOW COLUMNS FROM $table"); + if(MDB::isError($result)) { + return $result; } - if (!$db->getColumnNames($result,$columns)) { + $result2 = $db->getColumnNames($result, $columns); + if(MDB::isError($result)) { $db->freeResult($result); - return(0); + return $result2; } if (!isset($columns[$column = "field"]) && !isset($columns[$column = "type"])) { $db->freeResult($result); - return($db->setError("List table fields","show columns does not return the column $column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: show columns does not return the column '.$column); } $field_column = $columns["field"]; $type_column = $columns["type"]; @@ -284,7 +289,7 @@ break; default: - return($db->SetError("List table fields","unknown database attribute type")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: unknown database attribute type'); } unset($notnull); if (isset($columns["null"]) @@ -315,10 +320,10 @@ } } $db->freeResult($result); - if($success == DB_OK) { + if($success === DB_OK) { return(0); } - return($db->setError("List table fields","it was not specified an existing table column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: it was not specified an existing table column'); } function createSequence(&$db, $name, $start) @@ -377,13 +382,14 @@ function listSequences(&$db, &$sequences) { - if (!$db->queryColumn("SHOW TABLES",$table_names)) { - return(0); + $result = $db->queryColumn("SHOW TABLES", $sequences); + if(MDB::isError($result)) { + return $result; } $prefix_length = strlen($db->sequence_prefix); - for($sequences = array(),$table = 0;$table < count($table_names); ++$table) { - if (substr($table_names[$table], 0, $prefix_length) == $db->sequence_prefix) { - $sequences[] = substr($table_names[$table], $prefix_length); + for($sequences = array(),$sequence = 0;$sequence < count($sequences); ++$sequence) { + if (substr($sequences[$sequence], 0, $prefix_length) == $db->sequence_prefix) { + $sequences[] = substr($sequences[$sequence], $prefix_length); } } return(1); Index: pear/MDB/manager_common.php diff -u pear/MDB/manager_common.php:1.1 pear/MDB/manager_common.php:1.2 --- pear/MDB/manager_common.php:1.1 Thu May 30 10:35:02 2002 +++ pear/MDB/manager_common.php Fri May 31 13:28:25 2002 @@ -4,9 +4,9 @@ define("MDB_MANAGER_DATABASE_INCLUDED",1); /* - * manager_database.php + * manager_common.php * - * @(#) $Header: /usr/repository/pear/MDB/manager_common.php,v 1.1 2002/05/30 14:35:02 lsmith Exp $ + * @(#) $Header: /usr/repository/pear/MDB/manager_common.php,v 1.2 2002/05/31 17:28:25 lsmith Exp $ * */ @@ -52,7 +52,6 @@ $query = $db->getDecimalDeclaration($field_name, $field); break; default: - //return($this->setError("Get field", "type \"".$field["type"]."\" is not yet supported")); return $db->raiseError(DB_ERROR_UNSUPPORTED, "", "", "Get field: type \"".$field["type"]."\" is not yet supported"); break; } @@ -69,8 +68,9 @@ $query_fields.= ", "; } $field_name = key($fields); - if (!$this->getField(&$db, $fields[$field_name], $field_name, $query)) { - return(0); + $result = $this->getField(&$db, $fields[$field_name], $field_name, $query); + if (MDB::isError($result)) { + return $result; } $query_fields .= $query; } Index: pear/MDB/common.php diff -u pear/MDB/common.php:1.13 pear/MDB/common.php:1.14 --- pear/MDB/common.php:1.13 Thu May 30 10:35:02 2002 +++ pear/MDB/common.php Fri May 31 13:28:25 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.13 2002/05/30 14:35:02 lsmith Exp $ +// $Id: common.php,v 1.14 2002/05/31 17:28:25 lsmith Exp $ // // Base class for DB implementations. // @@ -229,9 +229,11 @@ if ($directory) { closedir($directory); } - return($this->SetError($scope,"it was not specified an existing $extension file ($include)")); + return $this->raiseError(DB_ERROR_LOADEXTENSION, "", "", + $scope.': it was not specified an existing '.$extension.' file ('.$include.')'); } else { - return($this->SetError($scope,"it was not specified a valid $extension include path")); + return $this->raiseError(DB_ERROR_LOADEXTENSION, "", "", + $scope.': it was not specified a valid '.$extension.' include path'); } } include($include_path.$separator.$include); @@ -244,14 +246,18 @@ if (isset($this->manager)) { return(1); } - if (!$this->loadExtension($scope, "database manager", "MDB_MANAGER_DATABASE_INCLUDED", "manager_common.php")) { - return(0); + $result = $this->loadExtension($scope, "database manager", "MDB_MANAGER_DATABASE_INCLUDED", "manager_common.php"); + if (MDB::isError($result)) { + return($result); } if (strlen($this->manager_class_name)) { if(strlen($this->manager_include) == 0) - return($this->SetError($scope, "it was not configured a valid database manager include file")); - if(!$this->loadExtension($scope, "database manager", $this->manager_included_constant, $this->manager_include)) - return(0); + return $this->raiseError(DB_LOADEXTENSION, "", "", + $scope.': it was not configured a valid database manager include file'); + $result = $this->loadExtension($scope, "database manager", $this->manager_included_constant, $this->manager_include); + if (MDB::isError($result)) { + return($result); + } $class_name = $this->manager_class_name; } else { $class_name = "MDB_manager_database_class"; @@ -262,104 +268,117 @@ function createDatabase($database) { - if(!$this->loadManager("Create database")) { - return(0); + $result = $this->loadManager("Create database"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createDatabase($this, $database)); } function dropDatabase($database) { - if(!$this->loadManager("Drop database")) { - return(0); + $result = $this->loadManager("Drop database"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropDatabase($this, $database)); } function createTable($name, &$fields) { - if(!$this->loadManager("Create table")) { - return(0); + $result = $this->loadManager("Create table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createTable($this, $name, $fields)); } function dropTable($name) { - if(!$this->loadManager("Drop table")) { - return(0); + $result = $this->loadManager("Drop table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropTable($this, $name)); } function alterTable($name, &$changes, $check) { - if(!$this->loadManager("Alter table")) { - return(0); + $result = $this->loadManager("Alter table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->alterTable($this, $name, $changes, $check)); } function listTables(&$tables) { - if(!$this->loadManager("List tables")) { - return(0); + $result = $this->loadManager("List tables"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listTables($this, $tables)); } function listTableFields($table, &$fields) { - if(!$this->loadManager("List table fields")) { - return(0); + $result = $this->loadManager("List table fields"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listTableFields($this, $table, $fields)); } function getTableFieldDefinition($table, $field, &$definition) { - if(!$this->loadManager("Get table field definition")) { - return(0); + $result = $this->loadManager("Get table field definition"); + if (MDB::isError($result)) { + return($result); } return($this->manager->getTableFieldDefinition($this, $table, $field, $definition)); } function createIndex($table, $name, &$definition) { - if(!$this->loadManager("Create index")) { - return(0); + $result = $this->loadManager("Create index"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createIndex($this, $table, $name, $definition)); } function dropIndex($table, $name) { - if(!$this->loadManager("Drop index")) { - return(0); + $result = $this->loadManager("Drop index"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropIndex($this, $table ,$name)); } function createSequence($name, $start) { - if(!$this->loadManager("Create sequence")) { - return(0); + $result = $this->loadManager("Create sequence"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createSequence($this, $name, $start)); } function dropSequence($name) { - if(!$this->loadManager("Drop sequence")) { - return(0); + $result = $this->loadManager("Drop sequence"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropSequence($this, $name)); } function listSequences(&$sequences) { - if(!$this->loadManager("List sequences")) { - return(0); + $result = $this->loadManager("List sequences"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listSequences($this, $sequences)); } @@ -936,7 +955,8 @@ break; default: if (!$this->ConvertResult($row[$column], $type)) { - return(0); + return $this->raiseError(DB_ERROR_INVALID, "", "", + 'convertResultRow: attempt to convert result value to an unknown type '.$type); } break; } @@ -1303,10 +1323,12 @@ function fetchField($result, &$value, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch field: it was not specified a valid result set'); } if ($this->endOfResult($result)) { - $success = $this->setError("Fetch field", "result set is empty"); + $success = $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch field: result set is empty'); } else { if ($this->resultIsNull($result, 0, 0)) { unset($value); @@ -1326,10 +1348,12 @@ function fetchRow($result, &$row, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch row: it was not specified a valid result set'); } if ($this->endOfResult($result)) { - $success = $this->setError("Fetch field", "result set is empty"); + $success = $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch row: result set is empty'); } else { $success = $this->fetchInto($result, $row, $fetchmode, 0); } @@ -1344,7 +1368,8 @@ function fetchColumn($result, &$column, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch column: it was not specified a valid result set'); } $temp = array(); for($success = 1, $column = array(), $row = 0;!$this->endOfResult($result); $row++) { @@ -1371,7 +1396,8 @@ function fetchAll($result, &$all, $fetchmode = DB_FETCHMODE_DEFAULT, $rekey = false, $force_array = false, $group = false) { if (!$result) { - return ($this->setError("Fetch field","it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch All: it was not specified a valid result set'); } if($rekey) { $cols = $this->numCols($result);
Index: pear/MDB/manager_mysql.php diff -u pear/MDB/manager_mysql.php:1.1 pear/MDB/manager_mysql.php:1.2 --- pear/MDB/manager_mysql.php:1.1 Thu May 30 10:35:02 2002 +++ pear/MDB/manager_mysql.php Fri May 31 13:28:25 2002 @@ -6,7 +6,7 @@ /* * manager_mysql.php * - * @(#) $Header: /usr/repository/pear/MDB/manager_mysql.php,v 1.1 2002/05/30 14:35:02 lsmith Exp $ + * @(#) $Header: /usr/repository/pear/MDB/manager_mysql.php,v 1.2 2002/05/31 17:28:25 lsmith Exp $ * */ @@ -30,7 +30,7 @@ return $result; } if (!mysql_drop_db($name, $this->connection)) { - return $$db->mysqlRaiseError(DB_ERROR_CANNOT_DROP); + return $db->mysqlRaiseError(DB_ERROR_CANNOT_DROP); } return (1); } @@ -141,14 +141,15 @@ $query .= "CHANGE $old_field_name ".$changes["RenamedFields"][$old_field_name]["Declaration"]; } } - return ($db->Query("ALTER TABLE $name $query")); + return ($db->query("ALTER TABLE $name $query")); } } function listTables(&$db, &$tables) { - if(!$db->queryColumn("SHOW TABLES",$table_names)) { - return(0); + $result = $db->queryColumn("SHOW TABLES", $table_names); + if(MDB::isError($result)) { + return $result; } $prefix_length = strlen($db->sequence_prefix); for($tables = array(), $table = 0; $table < count($table_names); ++$table) @@ -161,16 +162,18 @@ function listTableFields(&$db, $table, &$fields) { - if(!($result=$db->query("SHOW COLUMNS FROM $table"))) { - return(0); + $result = $db->query("SHOW COLUMNS FROM $table"); + if(MDB::isError($result)) { + return $result; } - if(!$db->getColumnNames($result, $columns)) { + $result2 = $db->getColumnNames($result, $columns); + if(MDB::isError($result2)) { $db->freeResult($result); - return(0); + return $result2; } if(!isset($columns["field"])) { $db->freeResult($result); - return($db->setError("List table fields","show columns does not return the table field names")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: show columns does not return the table field names'); } $field_column=$columns["field"]; for($fields=array(), $field = 0; !$db->endOfResult($result); ++$field) { @@ -186,20 +189,22 @@ { $field_name = strtolower($field); if ($field_name == $db->dummy_primary_key) { - return($db->SetError("List table fields",$db->dummy_primary_key." is an hidden column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: '.$db->dummy_primary_key.' is an hidden column'); } - if (!($result=$db->query("SHOW COLUMNS FROM $table"))) { - return(0); + $result = $db->query("SHOW COLUMNS FROM $table"); + if(MDB::isError($result)) { + return $result; } - if (!$db->getColumnNames($result,$columns)) { + $result2 = $db->getColumnNames($result, $columns); + if(MDB::isError($result)) { $db->freeResult($result); - return(0); + return $result2; } if (!isset($columns[$column = "field"]) && !isset($columns[$column = "type"])) { $db->freeResult($result); - return($db->setError("List table fields","show columns does not return the column $column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: show columns does not return the column '.$column); } $field_column = $columns["field"]; $type_column = $columns["type"]; @@ -284,7 +289,7 @@ break; default: - return($db->SetError("List table fields","unknown database attribute type")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: unknown database attribute type'); } unset($notnull); if (isset($columns["null"]) @@ -315,10 +320,10 @@ } } $db->freeResult($result); - if($success == DB_OK) { + if($success === DB_OK) { return(0); } - return($db->setError("List table fields","it was not specified an existing table column")); + return $db->raiseError(DB_ERROR_MANAGER, "", "", 'List table fields: it was not specified an existing table column'); } function createSequence(&$db, $name, $start) @@ -377,13 +382,14 @@ function listSequences(&$db, &$sequences) { - if (!$db->queryColumn("SHOW TABLES",$table_names)) { - return(0); + $result = $db->queryColumn("SHOW TABLES", $sequences); + if(MDB::isError($result)) { + return $result; } $prefix_length = strlen($db->sequence_prefix); - for($sequences = array(),$table = 0;$table < count($table_names); ++$table) { - if (substr($table_names[$table], 0, $prefix_length) == $db->sequence_prefix) { - $sequences[] = substr($table_names[$table], $prefix_length); + for($sequences = array(),$sequence = 0;$sequence < count($sequences); ++$sequence) { + if (substr($sequences[$sequence], 0, $prefix_length) == $db->sequence_prefix) { + $sequences[] = substr($sequences[$sequence], $prefix_length); } } return(1); Index: pear/MDB/manager_common.php diff -u pear/MDB/manager_common.php:1.1 pear/MDB/manager_common.php:1.2 --- pear/MDB/manager_common.php:1.1 Thu May 30 10:35:02 2002 +++ pear/MDB/manager_common.php Fri May 31 13:28:25 2002 @@ -4,9 +4,9 @@ define("MDB_MANAGER_DATABASE_INCLUDED",1); /* - * manager_database.php + * manager_common.php * - * @(#) $Header: /usr/repository/pear/MDB/manager_common.php,v 1.1 2002/05/30 14:35:02 lsmith Exp $ + * @(#) $Header: /usr/repository/pear/MDB/manager_common.php,v 1.2 2002/05/31 17:28:25 lsmith Exp $ * */ @@ -52,7 +52,6 @@ $query = $db->getDecimalDeclaration($field_name, $field); break; default: - //return($this->setError("Get field", "type \"".$field["type"]."\" is not yet supported")); return $db->raiseError(DB_ERROR_UNSUPPORTED, "", "", "Get field: type \"".$field["type"]."\" is not yet supported"); break; } @@ -69,8 +68,9 @@ $query_fields.= ", "; } $field_name = key($fields); - if (!$this->getField(&$db, $fields[$field_name], $field_name, $query)) { - return(0); + $result = $this->getField(&$db, $fields[$field_name], $field_name, $query); + if (MDB::isError($result)) { + return $result; } $query_fields .= $query; } Index: pear/MDB/common.php diff -u pear/MDB/common.php:1.13 pear/MDB/common.php:1.14 --- pear/MDB/common.php:1.13 Thu May 30 10:35:02 2002 +++ pear/MDB/common.php Fri May 31 13:28:25 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.13 2002/05/30 14:35:02 lsmith Exp $ +// $Id: common.php,v 1.14 2002/05/31 17:28:25 lsmith Exp $ // // Base class for DB implementations. // @@ -229,9 +229,11 @@ if ($directory) { closedir($directory); } - return($this->SetError($scope,"it was not specified an existing $extension file ($include)")); + return $this->raiseError(DB_ERROR_LOADEXTENSION, "", "", + $scope.': it was not specified an existing '.$extension.' file ('.$include.')'); } else { - return($this->SetError($scope,"it was not specified a valid $extension include path")); + return $this->raiseError(DB_ERROR_LOADEXTENSION, "", "", + $scope.': it was not specified a valid '.$extension.' include path'); } } include($include_path.$separator.$include); @@ -244,14 +246,18 @@ if (isset($this->manager)) { return(1); } - if (!$this->loadExtension($scope, "database manager", "MDB_MANAGER_DATABASE_INCLUDED", "manager_common.php")) { - return(0); + $result = $this->loadExtension($scope, "database manager", "MDB_MANAGER_DATABASE_INCLUDED", "manager_common.php"); + if (MDB::isError($result)) { + return($result); } if (strlen($this->manager_class_name)) { if(strlen($this->manager_include) == 0) - return($this->SetError($scope, "it was not configured a valid database manager include file")); - if(!$this->loadExtension($scope, "database manager", $this->manager_included_constant, $this->manager_include)) - return(0); + return $this->raiseError(DB_LOADEXTENSION, "", "", + $scope.': it was not configured a valid database manager include file'); + $result = $this->loadExtension($scope, "database manager", $this->manager_included_constant, $this->manager_include); + if (MDB::isError($result)) { + return($result); + } $class_name = $this->manager_class_name; } else { $class_name = "MDB_manager_database_class"; @@ -262,104 +268,117 @@ function createDatabase($database) { - if(!$this->loadManager("Create database")) { - return(0); + $result = $this->loadManager("Create database"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createDatabase($this, $database)); } function dropDatabase($database) { - if(!$this->loadManager("Drop database")) { - return(0); + $result = $this->loadManager("Drop database"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropDatabase($this, $database)); } function createTable($name, &$fields) { - if(!$this->loadManager("Create table")) { - return(0); + $result = $this->loadManager("Create table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createTable($this, $name, $fields)); } function dropTable($name) { - if(!$this->loadManager("Drop table")) { - return(0); + $result = $this->loadManager("Drop table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropTable($this, $name)); } function alterTable($name, &$changes, $check) { - if(!$this->loadManager("Alter table")) { - return(0); + $result = $this->loadManager("Alter table"); + if (MDB::isError($result)) { + return($result); } return($this->manager->alterTable($this, $name, $changes, $check)); } function listTables(&$tables) { - if(!$this->loadManager("List tables")) { - return(0); + $result = $this->loadManager("List tables"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listTables($this, $tables)); } function listTableFields($table, &$fields) { - if(!$this->loadManager("List table fields")) { - return(0); + $result = $this->loadManager("List table fields"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listTableFields($this, $table, $fields)); } function getTableFieldDefinition($table, $field, &$definition) { - if(!$this->loadManager("Get table field definition")) { - return(0); + $result = $this->loadManager("Get table field definition"); + if (MDB::isError($result)) { + return($result); } return($this->manager->getTableFieldDefinition($this, $table, $field, $definition)); } function createIndex($table, $name, &$definition) { - if(!$this->loadManager("Create index")) { - return(0); + $result = $this->loadManager("Create index"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createIndex($this, $table, $name, $definition)); } function dropIndex($table, $name) { - if(!$this->loadManager("Drop index")) { - return(0); + $result = $this->loadManager("Drop index"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropIndex($this, $table ,$name)); } function createSequence($name, $start) { - if(!$this->loadManager("Create sequence")) { - return(0); + $result = $this->loadManager("Create sequence"); + if (MDB::isError($result)) { + return($result); } return($this->manager->createSequence($this, $name, $start)); } function dropSequence($name) { - if(!$this->loadManager("Drop sequence")) { - return(0); + $result = $this->loadManager("Drop sequence"); + if (MDB::isError($result)) { + return($result); } return($this->manager->dropSequence($this, $name)); } function listSequences(&$sequences) { - if(!$this->loadManager("List sequences")) { - return(0); + $result = $this->loadManager("List sequences"); + if (MDB::isError($result)) { + return($result); } return($this->manager->listSequences($this, $sequences)); } @@ -936,7 +955,8 @@ break; default: if (!$this->ConvertResult($row[$column], $type)) { - return(0); + return $this->raiseError(DB_ERROR_INVALID, "", "", + 'convertResultRow: attempt to convert result value to an unknown type '.$type); } break; } @@ -1303,10 +1323,12 @@ function fetchField($result, &$value, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch field: it was not specified a valid result set'); } if ($this->endOfResult($result)) { - $success = $this->setError("Fetch field", "result set is empty"); + $success = $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch field: result set is empty'); } else { if ($this->resultIsNull($result, 0, 0)) { unset($value); @@ -1326,10 +1348,12 @@ function fetchRow($result, &$row, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch row: it was not specified a valid result set'); } if ($this->endOfResult($result)) { - $success = $this->setError("Fetch field", "result set is empty"); + $success = $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch row: result set is empty'); } else { $success = $this->fetchInto($result, $row, $fetchmode, 0); } @@ -1344,7 +1368,8 @@ function fetchColumn($result, &$column, $fetchmode = DB_FETCHMODE_DEFAULT) { if (!$result) { - return ($this->setError("Fetch field", "it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch column: it was not specified a valid result set'); } $temp = array(); for($success = 1, $column = array(), $row = 0;!$this->endOfResult($result); $row++) { @@ -1371,7 +1396,8 @@ function fetchAll($result, &$all, $fetchmode = DB_FETCHMODE_DEFAULT, $rekey = false, $force_array = false, $group = false) { if (!$result) { - return ($this->setError("Fetch field","it was not specified a valid result set")); + return $this->raiseError(DB_ERROR_NEED_MORE_DATA, "", "", + 'Fetch All: it was not specified a valid result set'); } if($rekey) { $cols = $this->numCols($result);