本文整理汇总了PHP中MDB::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB::isError方法的具体用法?PHP MDB::isError怎么用?PHP MDB::isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB
的用法示例。
在下文中一共展示了MDB::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
# $Id$
# Index is just a stub to redirect to the appropriate view
# as defined in config.inc.php using the variable $default_view
# If $default_room is defined in config.inc.php then this will
# be used to redirect to a particular room.
require_once "grab_globals.inc.php";
include "config.inc.php";
require_once "database.inc.php";
require "{$dbsys}.inc";
$day = date("d");
$month = date("m");
$year = date("Y");
switch ($default_view) {
case "month":
$redirect_str = "month.php?year={$year}&month={$month}";
break;
case "week":
$redirect_str = "week.php?year={$year}&month={$month}&day={$day}";
break;
default:
$redirect_str = "day.php?day={$day}&month={$month}&year={$year}";
}
if (!empty($default_room)) {
$sql = "SELECT area_id FROM mrbs_room WHERE id={$default_room}";
$area = $mdb->queryOne($sql);
if (!MDB::isError($area)) {
$room = $default_room;
$redirect_str .= "&area={$area}&room={$room}";
}
}
header("Location: {$redirect_str}");
示例2: sql_syntax_caseless_contains
if (!empty($creatormatch)) {
$sql .= " AND" . sql_syntax_caseless_contains("e.create_by", $creatormatch);
}
if ($sortby == "r") {
# Order by Area, Room, Start date/time
$sql .= " ORDER BY 9,10,2";
} else {
# Order by Start date/time, Area, Room
$sql .= " ORDER BY 2,9,10";
}
if ($debug_flag) {
echo "<p>DEBUG: SQL: <tt> {$sql} </tt>\n";
}
$types = array('integer', 'integer', 'integer', 'text', 'text', 'text', 'text', 'timestamp', 'text', 'text');
$res = $mdb->query($sql, $types);
if (MDB::isError($res)) {
fatal_error(0, $res->getMessage() . "\n" . $res->getUserInfo() . "\n");
}
$nmatch = $mdb->numRows($res);
if ($nmatch == 0) {
echo "<P><B>" . get_vocab("nothing_found") . "</B>\n";
$mdb->freeResult($res);
} else {
$last_area_room = "";
$last_date = "";
echo "<P><B>" . $nmatch . " " . ($nmatch == 1 ? get_vocab("entry_found") : get_vocab("entries_found")) . "</B>\n";
while ($row = $mdb->fetchInto($res)) {
if ($summarize & 1) {
reporton($row, $last_area_room, $last_date, $sortby, $display);
}
if ($summarize & 2) {
示例3: changePassword
/**
* Change password for user in the storage container
*
* @param string Username
* @param string The new password (plain text)
*/
function changePassword($username, $password)
{
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') {
$cryptFunction = 'strval';
} elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
$cryptFunction = 'md5';
}
$password = $cryptFunction($password);
$query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s", $this->options['table'], $this->options['passwordcol'], $this->db->getTextValue($password), $this->options['usernamecol'], $this->db->getTextValue($username));
$res = $this->query($query);
if (MDB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->code);
}
return true;
}
示例4: define
require_once 'PHPUnit/GUI/HTML.php';
define('DB_DSN', 'mysql://root@localhost/mdb_qt');
define('TABLE_USER', 'QueryTool_user');
define('TABLE_ADDRESS', 'QueryTool_address');
define('TABLE_QUESTION', 'question');
define('TABLE_ANSWER', 'answer');
$allTables = array(TABLE_USER, TABLE_ADDRESS, TABLE_QUESTION, TABLE_ANSWER);
require_once 'sql.php';
require_once 'UnitTest.php';
require_once 'Common.php';
//
// common setup (this actually also does the tearDown, since we have the DROP TABLE queries in the setup too
//
$querytool = new tests_Common();
foreach ($dbStructure[$querytool->db->phptype]['setup'] as $aQuery) {
if (MDB::isError($ret = $querytool->db->query($aQuery))) {
//include_once 'Var_Dump.php';
//var_dump::display($ret);
die($ret->getUserInfo());
}
}
//
// run the test suite
//
require_once 'PHPUnit/GUI/SetupDecorator.php';
$gui = new PHPUnit_GUI_SetupDecorator(new PHPUnit_GUI_HTML());
$gui->getSuitesFromDir(dirname(__FILE__), '.*\\.php', array('UnitTest.php', 'Common.php', 'sql.php', 'index.php'));
$gui->show();
/*
require_once 'Get.php';
require_once 'GetAll.php';
示例5: elseif
include "trailer.inc";
exit;
}
if (!isset($search_pos) || $search_pos <= 0) {
$search_pos = 0;
} elseif ($search_pos >= $total) {
$search_pos = $total - $total % $search["count"];
}
# Now we set up the "real" query using LIMIT to just get the stuff we want.
$sql = "SELECT E.id, E.create_by, E.name, E.description, E.start_time, R.area_id\n FROM mrbs_entry E, mrbs_room R\n WHERE {$sql_pred}\n AND E.room_id = R.id\n ORDER BY E.start_time asc";
if ($debug_flag) {
echo "<p>DEBUG: SQL: <tt> {$sql} </tt><BR>";
}
$types = array('integer', 'text', 'text', 'text', 'integer', 'integer');
$result = $mdb->limitQuery($sql, $types, $search_pos, $search["count"]);
if (MDB::isError($mdb)) {
fatal_error(0, $result->getMessage() . "\n" . $result->getUserInfo() . "\n");
}
$num_records = $mdb->numRows($result);
$has_prev = $search_pos > 0;
$has_next = $search_pos < $total - $search["count"];
if ($has_prev || $has_next) {
echo "<B>" . get_vocab("records") . ($search_pos + 1) . get_vocab("through") . ($search_pos + $num_records) . get_vocab("of") . $total . "</B><BR>";
# display a "Previous" button if necessary
if ($has_prev) {
echo "<A HREF=\"search.php?search_str={$search_url}&search_pos=";
echo max(0, $search_pos - $search["count"]);
echo "&total={$total}&year={$year}&month={$month}&day={$day}\">";
}
echo "<B>" . get_vocab("previous") . "</B>";
if ($has_prev) {
示例6: array
// Set $db_create to 0 to NOT create the database.
$db_create = 1;
// Communication protocol tu use. For pgsql, you can use 'unix' instead of
// 'tcp' to use Unix Domain Sockets instead of TCP/IP.
$db_protocol = "tcp";
/**************************
* DBMS specific options
***************************/
//****ORACLE*****
// Home directory path where Oracle is installed if it is running in the local machine.
// Default value: value of the environment variable ORACLE_HOME
$oci8_home = "";
/**************************
* End of database settings
***************************/
include_once "MDB.php";
MDB::loadFile("Manager");
$schema_file = "mrbs.schema.xml";
$variables = array("database_name" => $db_database, "database_create" => $db_create);
$dsn = array("phptype" => $dbsys, "username" => $db_login, "password" => $db_password, "hostspec" => $db_host, "protocol" => $db_protocol, "port" => $db_port);
$options = array("HOME" => $oci8_home, "optimize" => 'portability');
$manager = new MDB_manager();
$manager->connect($dsn, $options);
$success = $manager->updateDatabase($schema_file, $schema_file . ".before", $variables);
if (MDB::isError($success)) {
echo "Error: " . $success->getMessage() . "<BR>";
echo "Error: " . $success->getUserInfo() . "<BR>";
}
if (count($manager->warnings) > 0) {
echo "WARNING:<BR>", implode($manager->getWarnings(), "!\n"), "\n";
}
示例7: testUpdateDatabase
function testUpdateDatabase()
{
if (!$this->methodExists($this->manager, 'updateDatabase')) {
return;
}
$backup_file = $this->driver_input_file . $this->backup_extension;
if (!file_exists($backup_file)) {
copy($this->driver_input_file, $backup_file);
}
$result = $this->manager->updateDatabase($this->driver_input_file, $backup_file, array('create' => '0', 'name' => $this->database));
if (!MDB::isError($result)) {
$backup_file = $this->lob_input_file . $this->backup_extension;
if (!file_exists($backup_file)) {
copy($this->lob_input_file, $backup_file);
}
$result = $this->manager->updateDatabase($this->lob_input_file, $backup_file, array('create' => '0', 'name' => $this->database));
}
$this->assertFalse(MDB::isError($result), 'Error updating database');
}
示例8: readGroups
/**
* LiveUser_Perm_Container_MDB_Complex::readGroups()
*
* Reads all the group ids in that the user is also a member of
* (all groups that are subgroups of these are also added recursively)
*
* @access private
* @see readRights()
* @return void
*/
function readGroups()
{
parent::readGroups();
$result = $this->groupIds;
// get all subgroups recursively
while (count($result) > 0) {
$query = '
SELECT
DISTINCT SG.subgroup_id
FROM
' . $this->prefix . 'groups G,
' . $this->prefix . 'group_subgroups SG
WHERE
SG.subgroup_id = G.group_id
AND
SG.group_id IN (' . implode(', ', $result) . ')
AND
SG.subgroup_id NOT IN (' . implode(', ', $this->groupIds) . ')
AND
G.is_active=' . $this->dbc->getValue('boolean', true);
$result = $this->dbc->queryCol($query);
if (MDB::isError($result)) {
break;
} else {
$this->groupIds = array_merge($result, $this->groupIds);
}
}
}
示例9: execute
/**
*
* @param string $query
* @param string method
* @return resultSet or false on error
* @access public
*/
function execute($query = null, $method = 'getAll')
{
$this->writeLog();
if (is_null($query)) {
$query = $this->_buildSelectQuery();
}
$this->writeLog('query built: ' . $query);
// FIXXME on ORACLE this doesnt work, since we return joined columns as _TABLE_COLNAME and the _ in front
// doesnt work on oracle, add a letter before it!!!
$this->_lastQuery = $query;
$this->debug($query);
$this->writeLog('start query');
if (MDB::isError($res = $this->db->{$method}($query))) {
if ($this->getOption('verbose')) {
//$this->_errorSet($this->db->errorMessage($res->getCode()));
$this->_errorSet($res->getMessage() . '-' . $res->getUserInfo());
} else {
//$this->_errorLog($this->db->errorMessage($res->getCode()));
$this->_errorLog($res->getMessage());
}
$this->_errorLog($res->getUserInfo(), __LINE__);
return false;
} else {
$this->writeLog('end query');
}
return $this->_makeIndexed($res);
}
示例10: query
/**
* Get QuerySim text from appropriate source and return
* the parsed text.
*
* @param string The QuerySim text
* @param mixed $types array that contains the types of the columns in
* the result set
*
* @access public
*
* @return mixed Simulated result set as a multidimentional
* array if valid QuerySim text was passed in. A MDB error
* is returned on failure.
*/
function query($query, $types = null)
{
if ($this->database_name) {
$query = $this->_readFile();
}
$this->debug("Query: {$query}");
$ismanip = false;
$first = $this->first_selected_row;
$limit = $this->selected_row_limit;
$this->last_query = $query;
if ($result = $this->_buildResult($query)) {
if ($types != null) {
if (!is_array($types)) {
$types = array($types);
}
if (MDB::isError($err = $this->setResultTypes($result, $types))) {
$this->freeResult($result);
return $err;
}
}
if ($limit > 0) {
$result[1] = array_slice($result[1], $first - 1, $limit);
}
$this->highest_fetched_row[$this->_querySimSignature($result)] = -1;
return $result;
}
return $this->raiseError();
}
示例11: array
# this page will display the start time of the series
# but edit_entry.php will display the start time of the entry
$types = array('integer');
$row = $mdb->queryRow("SELECT id\nFROM {$tbl_entry}\nWHERE repeat_id=\"{$id}\"\nORDER BY start_time", $types);
if (MDB::isError($row)) {
fatal_error(0, $row->getMessage() . "\n" . $row->getUserInfo() . "\n");
}
}
$id = $row[0];
sql_free($res);
} else {
$repeat_id = $row[11];
if ($repeat_id != 0) {
$types = array('integer', 'integer', 'text', 'integer');
$row = $mdb->queryRow("SELECT rep_type, end_date, rep_opt, rep_num_weeks\nFROM {$tbl_repeat} WHERE id={$repeat_id}", $types);
if (MDB::isError($row)) {
fatal_error(0, $row->getMessage() . "\n" . $row->getUserInfo() . "\n");
}
if (NULL != $row) {
$rep_type = $row[0];
$rep_end_date = utf8_strftime('%A %d %B %Y', $row[1]);
$rep_opt = $row[2];
$rep_num_weeks = $row[3];
}
}
}
$enable_periods ? toPeriodString($start_period, $duration, $dur_units) : toTimeString($duration, $dur_units);
$repeat_key = "rep_type_" . $rep_type;
# Now that we know all the data we start drawing it
?>
示例12: getTableFieldDefinition
/**
* get the stucture of a field into an array; this method is still alpha quality!
*
* @param object $db database object that is extended by this class
* @param string $table name of table that should be used in method
* @param string $field_name name of field that should be used in method
* @return mixed data array on success, a MDB error on failure
* @access public
*/
function getTableFieldDefinition(&$db, $table, $field_name)
{
$columns = $db->queryRow("EXEC sp_columns @table_name='{$table}',\n @column_name='{$field_name}'", NULL, MDB_FETCHMODE_ASSOC);
if (MDB::isError($columns)) {
return $columns;
}
if ($db->options['optimize'] != 'portability') {
array_change_key_case($columns);
}
if (!isset($columns[$column = 'column_name']) || !isset($columns[$column = 'type_name'])) {
return $db->raiseError(MDB_ERROR_MANAGER, NULL, NULL, 'Get table field definition: no result, please check table ' . $table . ' and field ' . $field_name . ' are correct');
}
$field_column = $columns['column_name'];
$type_column = $columns['type_name'];
$db_type = strtolower($type_column);
if (strpos($type_column, ' ') !== FALSE) {
$db_type = strtok($db_type, ' ');
}
$length = $columns['precision'];
$decimal = $columns['scale'];
$type = array();
switch ($db_type) {
case 'bigint':
case 'int':
case 'smallint':
case 'tinyint':
$type[0] = 'integer';
if ($length == '1') {
$type[1] = 'boolean';
}
break;
case 'bit':
$type[0] = 'integer';
$type[1] = 'boolean';
break;
case 'decimal':
case 'numeric':
$type[0] = 'decimal';
break;
case 'money':
case 'smallmoney':
$type[0] = 'decimal';
$type[1] = 'float';
break;
case 'float':
case 'real':
$type[0] = 'float';
break;
case 'datetime':
case 'smalldatetime':
$type[0] = 'timestamp';
break;
case 'char':
case 'varchar':
case 'nchar':
case 'nvarchar':
$type[0] = 'text';
if ($length == '1') {
$type[1] = 'boolean';
}
break;
case 'text':
case 'ntext':
$type[0] = 'clob';
$type[1] = 'text';
break;
case 'binary':
case 'varbinary':
case 'image':
$type[0] = 'blob';
break;
case 'timestamp':
$type[0] = 'blob';
break;
default:
return $db->raiseError(MDB_ERROR_MANAGER, NULL, NULL, 'List table fields: unknown database attribute type');
}
unset($notnull);
if ($columns['nullable'] == 0) {
$notnull = 1;
}
unset($default);
if (isset($columns['column_def']) && $columns['column_def'] != NULL) {
if ($type[0] = 'integer' or $type[0] = 'boolean') {
$columns['column_def'] = str_replace('(', '', $columns['column_def']);
$columns['column_def'] = str_replace(')', '', $columns['column_def']);
}
$default = $columns['column_def'];
}
$definition = array();
for ($field_choices = array(), $datatype = 0; $datatype < count($type); $datatype++) {
//.........这里部分代码省略.........
示例13: readGroupRights
/**
* Reads the group rights
* and put them in the array
*
* right => 1
*
* @access public
* @return mixed MDB_Error on failure or nothing
*/
function readGroupRights()
{
$this->groupRights = array();
if (count($this->groupIds)) {
$query = '
SELECT
GR.right_id,
MAX(GR.right_level)
FROM
' . $this->prefix . 'grouprights GR
WHERE
GR.group_id IN(' . implode(',', $this->groupIds) . ')
GROUP BY GR.right_id';
$types = array('integer', 'integer');
$result = $this->dbc->queryAll($query, $types, MDB_FETCHMODE_ORDERED, true);
if (MDB::isError($result)) {
return $result;
}
if (is_array($result)) {
$this->groupRights = $result;
}
}
}
示例14: endHandler
//.........这里部分代码省略.........
case 'float':
case 'decimal':
break;
default:
$this->raiseError('no valid field type ("' . $this->field['type'] . '") specified', $xp);
}
if (!isset($this->field['was'])) {
$this->field['was'] = $this->field_name;
}
if (isset($this->field['notnull']) && !$this->is_boolean($this->field['notnull'])) {
$this->raiseError('field "notnull" has to be 1 or 0', $xp);
}
if (isset($this->field['notnull']) && !isset($this->field['default'])) {
$this->raiseError('if field is "notnull", it needs a default value', $xp);
}
if (isset($this->field['unsigned']) && !$this->is_boolean($this->field['unsigned'])) {
$this->raiseError('field "notnull" has to be 1 or 0', $xp);
}
$this->table['FIELDS'][$this->field_name] = $this->field;
if (isset($this->field['default'])) {
if ($this->field['type'] == 'clob' || $this->field['type'] == 'blob') {
$this->raiseError('"' . $this->field['type'] . '"-fields are not allowed to have a default value', $xp);
}
if ($this->field['default'] !== '' && !$this->validateFieldValue($this->field_name, $this->field['default'], $xp)) {
$this->raiseError('default value of "' . $this->field_name . '" is of wrong type', $xp);
}
}
break;
/* Index declaration */
/* Index declaration */
case 'database-table-declaration-index':
if (!$this->index_name) {
$this->raiseError('an index needs a name', $xp);
}
if (isset($this->table['INDEXES'][$this->index_name])) {
$this->raiseError('index "' . $this->index_name . '" already exists', $xp);
}
if (isset($this->index['unique']) && !$this->is_boolean($this->index['unique'])) {
$this->raiseError('field "unique" has to be 1 or 0', $xp);
}
if (!isset($this->index['was'])) {
$this->index['was'] = $this->index_name;
}
$this->table['INDEXES'][$this->index_name] = $this->index;
break;
case 'database-table-declaration-index-field':
if (!$this->field_name) {
$this->raiseError('the index-field-name is required', $xp);
}
if (isset($this->field['sorting']) && $this->field['sorting'] !== 'ascending' && $this->field['sorting'] !== 'descending') {
$this->raiseError('sorting type unknown', $xp);
}
$this->index['FIELDS'][$this->field_name] = $this->field;
break;
/* Sequence declaration */
/* Sequence declaration */
case 'database-sequence':
if (!$this->seq_name) {
$this->raiseError('a sequence has to have a name', $xp);
}
if (isset($this->database_definition['SEQUENCES'][$this->seq_name])) {
$this->raiseError('sequence "' . $this->seq_name . '" already exists', $xp);
}
if (!isset($this->seq['was'])) {
$this->seq['was'] = $this->seq_name;
}
if (isset($this->seq['on'])) {
if (!isset($this->seq['on']['table']) || !$this->seq['on']['table'] || (!isset($this->seq['on']['field']) || !$this->seq['on']['field'])) {
$this->raiseError('sequence "' . $this->seq_name . '" was not properly defined', $xp);
}
}
$this->database_definition['SEQUENCES'][$this->seq_name] = $this->seq;
break;
/* End of File */
/* End of File */
case 'database':
if (isset($this->database_definition['create']) && !$this->is_boolean($this->database_definition['create'])) {
$this->raiseError('field "create" has to be 1 or 0', $xp);
}
if (isset($this->database_definition['overwrite']) && !$this->is_boolean($this->database_definition['overwrite'])) {
$this->raiseError('field "overwrite" has to be 1 or 0', $xp);
}
if (!isset($this->database_definition['name']) || !$this->database_definition['name']) {
$this->raiseError('database needs a name', $xp);
}
if (isset($this->database_definition['SEQUENCES'])) {
foreach ($this->database_definition['SEQUENCES'] as $seq_name => $seq) {
if (isset($seq['on']) && !isset($this->database_definition['TABLES'][$seq['on']['table']]['FIELDS'][$seq['on']['field']])) {
$this->raiseError('sequence "' . $seq_name . '" was assigned on unexisting field/table', $xp);
}
}
}
if (MDB::isError($this->error)) {
$this->database_definition = $this->error;
}
break;
}
unset($this->elements[--$this->count]);
$this->element = implode('-', $this->elements);
}
示例15: listSequences
/**
* list all sequences in the current database
*
* @param object $dbs database object that is extended by this class
* @return mixed data array on success, a MDB error on failure
* @access public
*/
function listSequences(&$db)
{
$table_names = $db->queryCol('SHOW TABLES');
if (MDB::isError($table_names)) {
return $table_names;
}
for ($i = 0, $j = count($table_names), $sequences = array(); $i < $j; ++$i) {
if ($sqn = $this->_isSequenceName($db, $table_names[$i])) {
$sequences[] = $sqn;
}
}
return $sequences;
}