本文整理汇总了PHP中MDB2::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::isError方法的具体用法?PHP MDB2::isError怎么用?PHP MDB2::isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_db_error
function check_db_error($sth, $file, $line)
{
if (MDB2::isError($sth)) {
$error_str = "File: {$file} (line {$line})<br />\n " . "<strong>" . $sth->getMessage() . "</strong><br />\n" . $sth->getUserInfo() . "<br />\n";
die($error_str);
}
}
示例2: perform
/**
* update user data
*
* @param array $data
* @return bool true or false on error
*/
function perform($data)
{
$this->B->{$data}['error'] = FALSE;
$error =& $this->B->{$data}['error'];
$this->B->{$data}['result'] = array();
$_result =& $this->B->{$data}['result'];
$comma = '';
foreach ($data['fields'] as $f) {
$_fields .= $comma . $f;
$comma = ',';
}
if (isset($data['order'])) {
$_order = $data['order'];
} else {
$_order = 'rights DESC, lastname ASC';
}
$sql = "\n SELECT\n {$_fields}\n FROM\n {$this->B->sys['db']['table_prefix']}user_users\n ORDER BY\n {$_order}";
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
$error = 'Unexpected error';
return FALSE;
}
if (is_object($result)) {
while ($row =& $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$tmp = array();
foreach ($data['fields'] as $f) {
$tmp[$f] = stripslashes($row[$f]);
}
$_result[] = $tmp;
}
}
return TRUE;
}
示例3: perform
/**
* Delete email list data and attachement folder
*
* @param array $data
*/
function perform(&$data)
{
if (empty($data['lid'])) {
trigger_error("'lid' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
$set = '';
$comma = '';
foreach ($data['data'] as $key => $val) {
$set .= $comma . $key . '=' . $val;
$comma = ',';
}
$sql = '
UPDATE
' . $this->B->sys['db']['table_prefix'] . 'earchive_lists
SET
' . $set . '
WHERE
lid=' . $data['lid'];
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
return TRUE;
}
示例4: dsn_connect
/**
* Connect to specific database
*
* @param string DSN for DB connections
* @return object PEAR database handle
* @access private
*/
function dsn_connect($dsn)
{
// Use persistent connections if available
$db_options = array('persistent' => $this->db_pconn, 'emulate_prepared' => $this->debug_mode, 'debug' => $this->debug_mode, 'debug_handler' => 'mdb2_debug_handler', 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);
if ($this->db_provider == 'pgsql') {
$db_options['disable_smart_seqname'] = true;
$db_options['seqname_format'] = '%s';
}
$dbh = MDB2::connect($dsn, $db_options);
if (MDB2::isError($dbh)) {
$this->db_error = TRUE;
$this->db_error_msg = $dbh->getMessage();
raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => $dbh->getUserInfo()), TRUE, FALSE);
} else {
if ($this->db_provider == 'sqlite') {
$dsn_array = MDB2::parseDSN($dsn);
if (!filesize($dsn_array['database']) && !empty($this->sqlite_initials)) {
$this->_sqlite_create_database($dbh, $this->sqlite_initials);
}
} else {
$dbh->setCharset('utf8');
}
}
return $dbh;
}
示例5: perform
/**
* update user data
*
* @param array $data
* @return bool true or false on error
*/
function perform($data)
{
$this->B->{$data}['error'] = FALSE;
$error =& $this->B->{$data}['error'];
$set = '';
$comma = '';
foreach ($data['fields'] as $key => $val) {
$set .= $comma . $key . '="' . $this->B->db->escape($val) . '"';
$comma = ',';
}
$sql = '
UPDATE
' . $this->B->sys['db']['table_prefix'] . 'user_users
SET
' . $set . '
WHERE
uid=' . $data['user_id'];
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
$error = 'Unexpected error';
return FALSE;
}
return TRUE;
}
示例6: perform
/**
* add message data
*
* @param array $data
*/
function perform(&$data)
{
$mid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'earchive_messages');
if (MDB2::isError($mid)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
$sql = '
INSERT INTO
' . $this->B->sys['db']['table_prefix'] . 'earchive_messages
(mid,lid,sender,subject,mdate,body,folder)
VALUES
(' . $mid . ',
' . $data['lid'] . ',
"' . $data['sender'] . '",
"' . $data['subject'] . '",
"' . $data['mdate'] . '",
"' . $data['body'] . '",
"' . $data['folder'] . '")';
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
return $mid;
}
示例7: perform
/**
* Check login data and set session vars and url forward on success
*
* @param array $data
*/
function perform($data)
{
$passwd = md5($data['passwd']);
$sql = "SELECT \n uid,\n rights\n FROM\n {$this->B->sys['db']['table_prefix']}user_users\n WHERE\n login='{$data['login']}'\n AND\n passwd='{$passwd}'\n AND\n status=2";
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
if ($result->numRows() == 1) {
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$this->B->session->set('logged_id_user', $row['uid']);
$this->B->session->set('logged_user_rights', $row['rights']);
$admin = '';
if (SF_SECTION == 'admin') {
$admin = '?admin=1';
}
$query = '';
if (isset($data['forward_urlvar'])) {
$amp = '?';
if (!empty($admin)) {
$amp = '&';
}
$query = $amp . base64_decode($data['forward_urlvar']);
}
@header('Location: ' . SF_BASE_LOCATION . '/index.php' . $admin . $query);
exit;
} else {
return FAlSE;
}
}
示例8: conectar
function conectar()
{
if (!isset($mdb2)) {
//Local
$db_name = 'root';
$db_password = '';
$db_server = 'localhost';
$db_database = 'coopcrucial';
//Nabica
/*$db_name = 'coopcrucial';
$db_password = 'Nabica2012';
$db_server = 'coopcrucial.db.5840507.hostedresource.com';
$db_database = 'coopcrucial';*/
$dsn = 'mysql://' . $db_name . ':' . $db_password . '@' . $db_server . '/' . $db_database;
try {
$mdb2 =& MDB2::factory($dsn, true);
if (MDB2::isError($mdb2)) {
die($mdb2->getmessage() . ' - ' . $mdb2->getUserInfo());
} else {
$mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC);
}
$mdb2 = array('mdb2' => $mdb2, 'dsn' => $dsn);
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
}
return $mdb2;
}
示例9: perform
/**
* add user
*
* @param array $data
* @return int user id or false on error
*/
function perform($data)
{
$this->B->{$data}['error'] = FALSE;
$error =& $this->B->{$data}['error'];
if ($this->login_exists($data['user_data']['login']) > 0) {
$error = 'Login exists';
return FALSE;
}
$uid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'user_users');
if (MDB2::isError($uid)) {
trigger_error($uid->getMessage() . "\n" . $uid->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
$error = 'Unexpected error';
return FALSE;
}
$sql = '
INSERT INTO
' . $this->B->sys['db']['table_prefix'] . 'user_users
(uid,forename,lastname,email,login,passwd,status,rights)
VALUES
(' . $uid . ',
"' . $data['user_data']['forename'] . '",
"' . $data['user_data']['lastname'] . '",
"' . $data['user_data']['email'] . '",
"' . $data['user_data']['login'] . '",
"' . $data['user_data']['passwd'] . '",
' . $data['user_data']['status'] . ',
' . $data['user_data']['rights'] . ')';
$res = $this->B->db->query($sql);
if (MDB2::isError($res)) {
trigger_error($res->getMessage() . "\n" . $res->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
$error = 'Unexpected error';
return FALSE;
}
return $uid;
}
示例10: perform
/**
* add list data in db table
*
* @param array $data
*/
function perform(&$data)
{
// get list messages attachment folder string
$list_folder = commonUtil::unique_md5_str();
if (!@mkdir(SF_BASE_DIR . '/data/earchive/' . $list_folder, SF_DIR_MODE)) {
trigger_error("Cannot create list messages attachment folder! Contact the administrator.\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
$lid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'earchive_lists');
if (MDB2::isError($lid)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
$sql = '
INSERT INTO
' . $this->B->sys['db']['table_prefix'] . 'earchive_lists
(lid,name,email,emailserver,description,folder,status)
VALUES
(' . $lid . ',
"' . $data['name'] . '",
"' . $data['email'] . '",
"' . $data['emailserver'] . '",
"' . $data['description'] . '",
"' . $list_folder . '",
' . $data['status'] . ')';
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
return TRUE;
}
示例11: perform
/**
* Assign array with message attachments data
*
* @param array $data
*/
function perform(&$data)
{
if (empty($data['mid']) || empty($data['var'])) {
trigger_error("'mid' or 'var' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
return FALSE;
}
// get var name to store the result
$this->B->{$data}['var'] = array();
$_result =& $this->B->{$data}['var'];
$comma = '';
foreach ($data['fields'] as $f) {
$_fields .= $comma . $f;
$comma = ',';
}
$sql = "\n SELECT\n {$_fields}\n FROM\n {$this->B->sys['db']['table_prefix']}earchive_attach\n WHERE\n mid={$data['mid']} \n ORDER BY\n file ASC";
$result = $this->B->db->query($sql);
if (MDB2::isError($result)) {
trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
}
$_result = array();
if (is_object($result)) {
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$tmp = array();
foreach ($data['fields'] as $f) {
$tmp[$f] = stripslashes($row[$f]);
}
$_result[] = $tmp;
}
}
return TRUE;
}
示例12: dbConnect
function dbConnect()
{
global $db_type;
global $db_user;
global $db_pass;
global $db_host;
global $db_name;
global $sql_regexp;
if (!(isset($db_user) && $db_user != "")) {
include_once "header.inc.php";
error(ERR_DB_NO_DB_USER);
include_once "footer.inc.php";
exit;
}
if (!(isset($db_pass) && $db_pass != "")) {
include_once "header.inc.php";
error(ERR_DB_NO_DB_PASS);
include_once "footer.inc.php";
exit;
}
if (!(isset($db_host) && $db_host != "")) {
include_once "header.inc.php";
error(ERR_DB_NO_DB_HOST);
include_once "footer.inc.php";
exit;
}
if (!(isset($db_name) && $db_name != "")) {
include_once "header.inc.php";
error(ERR_DB_NO_DB_NAME);
include_once "footer.inc.php";
exit;
}
if (!isset($db_type) || !($db_type == "mysql" || $db_type == "pgsql")) {
include_once "header.inc.php";
error(ERR_DB_NO_DB_TYPE);
include_once "footer.inc.php";
exit;
}
$dsn = "{$db_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}";
$db = MDB2::connect($dsn);
$db->setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);
if (MDB2::isError($db)) {
// Error handling should be put.
error(MYSQL_ERROR_FATAL, $db->getMessage());
}
// Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
/* erase info */
$mysql_pass = $dsn = '';
// Add support for regular expressions in both MySQL and PostgreSQL
if ($db_type == "mysql") {
$sql_regexp = "REGEXP";
} elseif ($db_type == "pgsql") {
$sql_regexp = "~";
} else {
error(ERR_DB_NO_DB_TYPE);
}
return $db;
}
示例13: perform
/**
* Check if version number has changed and perfom additional upgarde code
* Furthermore assign array with module menu names for the top right
* module html seletor
*
* @param array $data
*/
function perform($data)
{
// get os related separator to set include path
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$tmp_separator = ';';
} else {
$tmp_separator = ':';
}
// set include path to the PEAR packages
ini_set('include_path', SF_BASE_DIR . 'modules/common/PEAR' . $tmp_separator . ini_get('include_path'));
unset($tmp_separator);
// include PEAR DB class
include_once SF_BASE_DIR . 'modules/common/PEAR/MDB2.php';
// init system config array
$this->B->sys = array();
// include system config array $this->B->sys
if (file_exists(SF_BASE_DIR . 'modules/common/config/config.php')) {
include_once SF_BASE_DIR . 'modules/common/config/config.php';
}
// if setup was done
if ($this->B->sys['info']['status'] == TRUE) {
$this->B->dsn = array('phptype' => $this->B->sys['db']['type'], 'username' => $this->B->sys['db']['user'], 'password' => $this->B->sys['db']['passwd'], 'hostspec' => $this->B->sys['db']['host'], 'database' => $this->B->sys['db']['name']);
$this->B->db =& MDB2::connect($this->B->dsn);
if (MDB2::isError($this->B->db)) {
trigger_error('Cannot connect to the database: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
}
} else {
// switch to the admin section if we comes from the public section
if (SF_SECTION == 'public') {
@header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1');
exit;
}
// launch setup screen
include $this->B->M(MOD_COMMON, 'get_module_view', array('m' => 'setup', 'view' => 'index'));
// Send the output buffer to the client
ob_end_flush();
exit;
}
// Check for upgrade
if (MOD_COMMON_VERSION != (string) $this->B->sys['module']['common']['version']) {
// set the new version num of this module
$this->B->sys['module']['common']['version'] = MOD_COMMON_VERSION;
$this->B->system_update_flag = TRUE;
// include here additional upgrade code
}
if (SF_SECTION == 'admin') {
// sort handler array by name
ksort($this->B->handler_list);
// assign template handler names array
// this array is used to build the modul select form of the admin menu
$this->B->tpl_mod_list = array();
foreach ($this->B->handler_list as $key => $value) {
if ($value['menu_visibility'] == TRUE) {
$this->B->tpl_mod_list[$key] = $value;
}
}
}
}
示例14: connectDB
function connectDB()
{
global $_CONF;
$objConnID =& MDB2::factory($_CONF['db']['dsn']);
if (MDB2::isError($objConnID)) {
throw new Exception('Database connection failed: ' . $objConnID->getMessage(), SQL_CONN_ERROR);
}
return $objConnID;
}
示例15: getDBVersion
public function getDBVersion()
{
$query = 'SELECT * FROM v$version';
$res = $this->db->query($query);
if (MDB2::isError($res)) {
return parent::getDBVersion();
}
$row = $res->fetchRow(DB_FETCHMODE_ASSOC);
return isset($row['banner']) ? $row['banner'] : parent::getDBVersion();
}