本文整理汇总了PHP中DB::errno方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::errno方法的具体用法?PHP DB::errno怎么用?PHP DB::errno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::errno方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDatabaseTables
/**
* Ensure that all database tables are included as designed
*
* @return void
*/
public function testDatabaseTables()
{
if (!file_exists(SITE_ROOT . '/install/sql/structure.xml')) {
$this->markTestSkipped('The install folder is unavailable, can\'t run this test.');
}
$db = simplexml_load_file(SITE_ROOT . '/install/sql/structure.xml');
foreach ($db->database->table_structure as $table) {
$tablename = str_replace('phpvms_', TABLE_PREFIX, $table['name']);
DB::query('SELECT * FROM ' . $tablename . ' WHERE 1=1 LIMIT 1');
$this->assertNotEquals('1146', DB::errno(), "\"{$tablename}\" is missing");
if (DB::$errno == '1146') {
continue;
}
/* loop through all the columns returned by the above query and all the columns
from the fields in the xml file, and make sure they all match up, with the
fieldlist from the xml being the "master" outside loop which it looks up against */
$anyerrors = false;
$colinfo = DB::$DB->col_info;
foreach ($table->field as $field) {
$found = false;
foreach ($colinfo as $column) {
if ($column->name == $field['Field']) {
$found = true;
break;
}
}
$this->assertTrue($found, "Column {$field['Field']} from {$tablename} missing");
}
}
}
示例2: testRegisterUser
/**
* UserTest::testRegisterUser()
*
* @return void
*/
public function testRegisterUser()
{
$data = RegistrationData::addUser($this->registrationData);
$this->assertTrue($data, 'Reported error: ' . RegistrationData::$error);
$this->pilotid = RegistrationData::$pilotid;
$this->assertGreaterThan(0, $this->pilotid, 'Valid pilot ID');
$this->assertEquals(0, DB::errno(), 'User Registration');
# See if it was written
$this->pilot_data = PilotData::getPilotData($this->pilotid);
$this->assertObjectHasAttribute('pilotid', $this->pilot_data, 'Retrieve user data');
}
示例3: AddGroup
public static function AddGroup($groupname, $type)
{
$groupname = DB::escape($groupname);
if ($type != 'a' || $type != 'd') {
$type = 'd';
}
$query = "INSERT INTO " . TABLE_PREFIX . "groups (name, groupstype) VALUES ('{$groupname}', '{$type}')";
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
return true;
}
示例4: make
function make($rule = '', $num = 1, $cardval = array())
{
global $_G;
$this->rule = empty($rule) ? $this->set['rule'] : trim($rule);
if (empty($this->rule)) {
return -1;
}
$this->fail($num);
if (is_array($cardval)) {
foreach ($cardval as $key => $val) {
$sqlkey .= ", {$key}";
$sqlval .= ", '{$val}'";
}
}
for ($i = 0; $i < $num; $i++) {
if ($this->checkrule($this->rule)) {
$card = $this->rule;
foreach ($this->rulereturn as $key => $val) {
$search = array();
foreach ($val as $skey => $sval) {
$search[] = '/' . $this->rulekey[$key] . '/';
}
$card = preg_replace($search, $val, $card, 1);
}
} else {
return 0;
}
$sql = "INSERT INTO " . DB::table('common_card') . " (id, makeruid, dateline {$sqlkey})VALUES('{$card}', '{$_G['uid']}', '{$_G['timestamp']}' {$sqlval})";
DB::query($sql, 'SILENT');
if ($sqlerror = DB::error()) {
if (DB::errno() == 1062) {
$this->fail++;
if ($this->failmin > $this->fail) {
$num++;
} else {
$num = $i - 1;
}
} else {
DB::halt($sqlerror, $sql);
}
} else {
$this->succeed += intval(DB::affected_rows());
$this->cardlist[] = $card;
}
}
return true;
}
示例5: testEditUserData
function testEditUserData()
{
# Check a save profile
$save = PilotData::SaveProfile($this->pilotid, 'unittest2@email.com', 'PK', '', '', true);
$this->assertEqual(0, DB::errno());
#unset($save);
# Verify if data was written, and if it differs
$changeset1 = PilotData::GetPilotData($this->pilotid);
$this->assertNotEqual($changeset1, $this->pilot_data);
$this->assertNotEqual($changeset1->retired, $this->pilot_data->retired);
unset($data);
# Change it back
$save = PilotData::SaveProfile($this->pilotid, 'unittest@email.com', 'US', '', '', false);
$this->assertTrue($save, DB::error(), 'Reverting user data');
unset($save);
# And verify once more
$changeset2 = PilotData::GetPilotData($this->pilotid);
$this->assertNotEqual($changeset1, $changeset2);
$this->assertNotEqual($changeset1->retired, $changeset2->retired);
unset($changeset1);
unset($changeset2);
echo '<br />';
}
示例6: IncrementDLCount
public static function IncrementDLCount($id)
{
$sql = 'UPDATE ' . TABLE_PREFIX . 'downloads
SET hits=hits+1
WHERE id=' . intval($id);
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
return true;
}
示例7: updateProfile
/**
* Update a pilot, $params is an array of column_name=>value
*
* @param mixed $pilotid This is a description
* @param mixed $params This is a description
* @return mixed This is the return value description
*
*/
public static function updateProfile($pilotid, $params)
{
/*$params = array(
'pilotid' => '',
'code' => '',
'email' => '',
'location' => '',
'hub' => '',
'bgimage' => '',
'retired' => false,
);
*/
if (empty($pilotid)) {
return false;
}
if (!is_array($params)) {
return false;
}
/* Cleanup any specific parameters */
if (isset($params['location'])) {
$params['location'] = strtoupper($params['location']);
}
if (isset($params['pilotid'])) {
unset($params['pilotid']);
}
$sql = "UPDATE " . TABLE_PREFIX . "pilots SET ";
$sql .= DB::build_update($params);
$sql .= " WHERE `pilotid`={$pilotid}";
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
# Auto groups?
$groups = Config::get('PILOT_STATUS_TYPES');
if (isset($params['retired'])) {
$info = $groups[$params['retired']];
# Automatically add into these groups
if (is_array($info['group_add']) && count($info['group_add']) > 0) {
foreach ($info['group_add'] as $group) {
PilotGroups::addUsertoGroup($pilotid, $group);
}
}
if (is_array($info['group_remove']) && count($info['group_remove']) > 0) {
foreach ($info['group_remove'] as $group) {
PilotGroups::removeUserFromGroup($pilotid, $group);
}
}
}
return true;
}
示例8: query
/**
* Perform a query
*
* @param unknown_type $query
* @return boolean/int Returns true/false, or rows affected
*/
public static function query($query)
{
$ret = self::$DB->query($query);
self::$error = self::$DB->error;
self::$errno = self::$DB->errno;
self::$rows_affected = self::$num_rows = self::$DB->num_rows;
self::$insert_id = self::$DB->insert_id;
return $ret;
//self::$insert_id;
}
示例9: editExpense
/**
* Edit a certain expense
*/
public static function editExpense($id, $name, $cost, $type)
{
if ($name == '' || $cost == '') {
self::$lasterror = 'Name and cost must be entered';
return false;
}
$name = DB::escape($name);
$cost = DB::escape($cost);
$type = strtoupper($type);
if ($type == '') {
$type = 'M';
}
// Default as monthly
$sql = 'UPDATE ' . TABLE_PREFIX . "expenses\n\t\t\t\t\tSET `name`='{$name}', `cost`='{$cost}', `type`='{$type}'\n\t\t\t\t\tWHERE `id`={$id}";
DB::query($sql);
if (DB::errno() != 0) {
return false;
}
return true;
}
示例10: saveSetting
/**
* Save site settings
*
* @param string $name Setting name. Must be unique
* @param string $value Value of the setting
* @param boolean $core Whether it's "vital" to the engine or not. Bascially blocks deletion
*/
public static function saveSetting($name, $value, $descrip = '', $core = false)
{
if (is_bool($value)) {
if ($value == true) {
$value = 'true';
} elseif ($value == false) {
$value = 'false';
}
}
//see if it's an update
if ($core == true) {
$core = 't';
} else {
$core = 'f';
}
$name = strtoupper(DB::escape($name));
$value = DB::escape($value);
$descrip = DB::escape($descrip);
$sql = 'UPDATE ' . TABLE_PREFIX . 'settings
SET value=\'' . $value . '\' WHERE name=\'' . $name . '\'';
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
CodonCache::delete('site_settings');
return true;
}
示例11: show_error
public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '')
{
global $_G;
ob_end_clean();
$gzip = getglobal('gzipcompress');
ob_start($gzip ? 'ob_gzhandler' : null);
$host = $_SERVER['HTTP_HOST'];
$title = $type == 'db' ? 'Database' : 'System';
//出错处理 改为记日志而不是直接输出到页面
$messagesave = $host . '\\r' . $title . '\\r\\n' . $errormsg;
!empty($phpmsg) && ($messagesave = $messagesave . '\\r\\n' . var_export($phpmsg, true));
discuz_error::write_error_log($messagesave);
header("Location: /");
exit;
echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
\t<title>{$host} - {$title} Error</title>
\t<meta http-equiv="Content-Type" content="text/html; charset={$_G['config']['output']['charset']}" />
\t<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
\t<style type="text/css">
\t<!--
\tbody { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;}
\t#container { width: 1024px; }
\t#message { width: 1024px; color: black; }
\t.red {color: red;}
\ta:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; }
\ta:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
\th1 { color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;}
\t.bg1{ background-color: #FFFFCC;}
\t.bg2{ background-color: #EEEEEE;}
\t.table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"}
\t.info {
\t background: none repeat scroll 0 0 #F3F3F3;
\t border: 0px solid #aaaaaa;
\t border-radius: 10px 10px 10px 10px;
\t color: #000000;
\t font-size: 11pt;
\t line-height: 160%;
\t margin-bottom: 1em;
\t padding: 1em;
\t}
\t.help {
\t background: #F3F3F3;
\t border-radius: 10px 10px 10px 10px;
\t font: 12px verdana, arial, sans-serif;
\t text-align: center;
\t line-height: 160%;
\t padding: 1em;
\t}
\t.sql {
\t background: none repeat scroll 0 0 #FFFFCC;
\t border: 1px solid #aaaaaa;
\t color: #000000;
\t font: arial, sans-serif;
\t font-size: 9pt;
\t line-height: 160%;
\t margin-top: 1em;
\t padding: 4px;
\t}
\t-->
\t</style>
</head>
<body>
<div id="container">
<h1>Discuz! {$title} Error</h1>
<div class='info'>{$errormsg}</div>
EOT;
if (!empty($phpmsg)) {
echo '<div class="info">';
echo '<p><strong>PHP Debug</strong></p>';
echo '<table cellpadding="5" cellspacing="1" width="100%" class="table">';
if (is_array($phpmsg)) {
echo '<tr class="bg2"><td>No.</td><td>File</td><td>Line</td><td>Code</td></tr>';
foreach ($phpmsg as $k => $msg) {
$k++;
echo '<tr class="bg1">';
echo '<td>' . $k . '</td>';
echo '<td>' . $msg['file'] . '</td>';
echo '<td>' . $msg['line'] . '</td>';
echo '<td>' . $msg['function'] . '</td>';
echo '</tr>';
}
} else {
echo '<tr><td><ul>' . $phpmsg . '</ul></td></tr>';
}
echo '</table></div>';
}
$helplink = '';
if ($type == 'db') {
$helplink = "http://faq.comsenz.com/?type=mysql&dberrno=" . rawurlencode(DB::errno()) . "&dberror=" . rawurlencode(str_replace(DB::object()->tablepre, '', DB::error()));
$helplink = "<a href=\"{$helplink}\" target=\"_blank\"><span class=\"red\">Need Help?</span></a>";
}
$endmsg = lang('error', 'error_end_message', array('host' => $host));
//.........这里部分代码省略.........
示例12: deleteAllAirports
public static function deleteAllAirports()
{
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'airports';
$res = DB::query($sql);
if (DB::errno() != 0) {
return false;
}
return true;
}
示例13: query
/**
* Perform a query
*
* @param unknown_type $query
* @return boolean/int Returns true/false, or rows affected
*/
public static function query($query)
{
self::$DB->throw_exceptions = self::$throw_exceptions;
$ret = self::$DB->query($query);
self::$error = self::$DB->error;
self::$errno = self::$DB->errno;
self::$rows_affected = self::$num_rows = self::$DB->num_rows;
self::$insert_id = self::$DB->insert_id;
self::$last_query = $query;
// Log any erronious queries
if (self::$DB->errno != 0) {
self::write_debug();
}
return $ret;
//self::$insert_id;
}
示例14: getatidheap
}
$firstlist = getatidheap($threadlist);
$tidsarray = array_keys($threadlist);
if (!empty($firstlist['tids'])) {
$continue = true;
}
if ($continue) {
foreach ($firstlist['tids'] as $tid) {
$posttableid = $threadlist[$tid]['posttableid'];
if ($posttableid == $_G['gp_tableid']) {
continue;
}
$posttable_source = $posttableid ? "forum_post_{$posttableid}" : 'forum_post';
$posttable_target = $_G['gp_tableid'] ? "forum_post_{$_G['gp_tableid']}" : 'forum_post';
DB::query("INSERT INTO " . DB::table($posttable_target) . " SELECT * FROM " . DB::table($posttable_source) . " WHERE tid='{$tid}'", 'SILENT');
if (DB::errno()) {
DB::delete($posttable_target, "tid='{$tid}'");
DB::query("INSERT INTO " . DB::table($posttable_target) . " SELECT * FROM " . DB::table($posttable_source) . " WHERE tid='{$tid}'");
}
DB::update($threadtable, array('posttableid' => intval($_G['gp_tableid'])), "tid='{$tid}'");
DB::delete($posttable_source, "tid='{$tid}'");
}
$completed = intval($_G['gp_completed']) + count($firstlist['tids']);
foreach ($firstlist['tids'] as $tid) {
unset($threadlist[$tid]);
}
$nextstep = $step + 1;
cpmsg('postsplit_moving', "action=postsplit&operation=move&{$_G['gp_urladd']}&tableid={$_G['gp_tableid']}&completed={$completed}&threadtomove={$_G['gp_threadtomove']}&step={$nextstep}&moving=1", 'loadingform', array('count' => $completed, 'total' => intval($_G['gp_threadtomove']), 'tids' => implode(',', array_keys($threadlist)), 'threads_per_time' => $_G['gp_threads_per_time'], 'conditions' => stripslashes(htmlspecialchars($_G['gp_conditions']))));
}
cpmsg('postsplit_move_succeed', "action=postsplit&operation=manage", 'succeed');
}
示例15: delete_schedule_post
protected function delete_schedule_post()
{
$schedule = SchedulesData::findSchedules(array('s.id' => $this->post->id));
SchedulesData::DeleteSchedule($this->post->id);
$params = array();
if (DB::errno() != 0) {
$params['status'] = 'There was an error deleting the schedule';
$params['error'] = DB::error();
echo json_encode($params);
return;
}
$params['status'] = 'ok';
echo json_encode($params);
LogData::addLog(Auth::$userinfo->pilotid, 'Deleted schedule "' . $schedule->code . $schedule->flightnum . '"');
}