本文整理汇总了PHP中DB::object方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::object方法的具体用法?PHP DB::object怎么用?PHP DB::object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
global $_G;
//////////////////////////
$fields = "\n\t\t\t`skey` varchar(255) NOT NULL default '',\n\t\t\t`svalue` text NOT NULL,\n\t\t\tPRIMARY KEY (`skey`)\n\t\t";
//////////////////////
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
//$type = 'debug';
if ($type) {
if (DB::num_rows($query)) {
DB::query('DROP TABLE ' . DB::table($this->_table));
}
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
} else {
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
}
示例2: db_error
function db_error($message, $sql)
{
global $_G;
list($showtrace, $logtrace) = discuz_error::debug_backtrace();
$title = lang('error', 'db_' . $message);
$title_msg = lang('error', 'db_error_message');
$title_sql = lang('error', 'db_query_sql');
$title_backtrace = lang('error', 'backtrace');
$title_help = lang('error', 'db_help_link');
$db =& DB::object();
$dberrno = $db->errno();
$dberror = str_replace($db->tablepre, '', $db->error());
$sql = htmlspecialchars(str_replace($db->tablepre, '', $sql));
$msg = '<li>[Type] ' . $title . '</li>';
$msg .= $dberrno ? '<li>[' . $dberrno . '] ' . $dberror . '</li>' : '';
$msg .= $sql ? '<li>[Query] ' . $sql . '</li>' : '';
discuz_error::show_error('db', $msg, $showtrace, false);
unset($msg, $phperror);
$errormsg = '<b>' . $title . '</b>';
$errormsg .= "[{$dberrno}]<br /><b>ERR:</b> {$dberror}<br />";
if ($sql) {
$errormsg .= '<b>SQL:</b> ' . $sql;
}
$errormsg .= "<br />";
$errormsg .= '<b>PHP:</b> ' . $logtrace;
discuz_error::write_error_log($errormsg);
exit;
}
示例3: getAttachment
public function getAttachment()
{
global $_G;
try {
$taskData = $this->checkTask();
} catch (Exception $e) {
throw new Cloud_Exception($e);
}
$task = $taskData['task'];
$attach = $taskData['attach'];
$taskId = $task['taskid'];
C::t('#qqconnect#connect_disktask')->update($taskId, array('status' => 1, 'downloadtime' => $_G['timestamp']));
$db = DB::object();
$db->close();
ob_end_clean();
$attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']) . '"';
dheader('Content-Type: application/octet-stream');
dheader('Content-Length: ' . $attach['filesize']);
dheader('Content-Disposition: attachment; filename=' . $attach['filename']);
self::_checkXSendFile($attach['attachment']);
if ($attach['remote']) {
self::_getRemoteFile($attach['attachment']);
} else {
self::_getLocalFile($attach['attachment']);
}
exit;
}
示例4: siteinformation
function siteinformation()
{
global $_G, $siteuniqueid, $save_mastermobile;
$db = DB::object();
$update = array('uniqueid' => $siteuniqueid, 'bbname' => $_G['setting']['bbname'], 'version' => XPLUS_VERSION, 'release' => XPLUS_RELEASE, 'php' => PHP_VERSION, 'mysql' => $db->version(), 'charset' => CHARSET, 'software' => $_SERVER['SERVER_SOFTWARE'], 'mastermobile' => $save_mastermobile, 'email' => $_G['member']['email']);
$updatetime = @filemtime(DISCUZ_ROOT . './data/updatetime.lock');
if (empty($updatetime) || TIMESTAMP - $updatetime > 3600 * 4) {
@touch(DISCUZ_ROOT . './data/updatetime.lock');
$table = array('common_attachment' => 'attachments', 'common_member' => 'members');
$modulespecialqueries = $modulearr = array();
$query = DB::query("SELECT identifier FROM " . DB::table('common_module'));
while ($row = DB::fetch($query)) {
$modulearr[] = $module = $row['identifier'];
$moduleinformation = null;
@(include libfile('module/' . $module));
if ($module && $moduleinformation) {
foreach ($moduleinformation as $value) {
if ($value['table'] && $value['returnkey']) {
$moduletable = $module . '_' . $value['table'];
$returnkey = $module . '_' . $value['returnkey'];
$conditions = $value['conditions'];
if (!empty($conditions) && $value['col']) {
$modulespecialqueries[$returnkey] = "SELECT {$value['col']} FROM " . DB::table($moduletable) . " WHERE {$conditions} LIMIT 0, 1";
} else {
$table[$moduletable] = $returnkey;
}
}
}
}
}
$update['module'] = implode(',', $modulearr);
if ($modulespecialqueries) {
foreach ($modulespecialqueries as $key => $value) {
$update[$key] = DB::result_first($value);
}
}
$tableprelen = strlen($db->tablepre);
$query = DB::query("SHOW TABLE STATUS");
while ($row = DB::fetch($query)) {
$tablename = substr($row['Name'], $tableprelen);
if (!isset($table[$tablename])) {
continue;
}
$update[$table[$tablename]] = $row['Rows'];
}
}
if (!empty($update['poll_items'])) {
$update['poll_nitems'] = $update['poll_items'] - $update['poll_pitems'];
unset($update['poll_items']);
}
$data = '';
foreach ($update as $key => $value) {
$data .= $key . '=' . rawurlencode($value) . '&';
}
return 'os=xplus&update=' . rawurlencode(base64_encode($data)) . '&md5hash=' . substr(md5($_SERVER['HTTP_USER_AGENT'] . implode('', $update) . TIMESTAMP), 8, 8) . '×tamp=' . TIMESTAMP;
}
示例5: _fetch_data
function _fetch_data($block_id)
{
global $_G, $postlist, $config, $authorid, $new_window, $tid, $hott;
$db = DB::object();
$tablepre = $db->tablepre;
$limit = $config['show_limit'] > 0 ? $config['show_limit'] : '6';
$only_lz = $hott[$block_id]['only_lz'] ? ' AND uid=' . $authorid : '';
$date_limit = $config['date_limit'] == 0 ? '' : ' AND dateline>' . ($_G['timestamp'] - $config['date_limit'] * 86400);
$query = DB::query("SELECT blogid,subject FROM {$tablepre}home_blog WHERE blogid>0 {$only_lz}{$date_limit} ORDER BY dateline DESC LIMIT 0,{$limit}");
while ($thread = DB::fetch($query)) {
$hott_block[] = array('link' => "home.php?mod=space&do=blog&id={$thread[blogid]}", 'link_info' => $new_window, 'subject' => cutstr($thread['subject'], $config['max_text']));
}
return (array) $hott_block;
}
示例6: showtablecloumn
public static function showtablecloumn($tablename)
{
$data = array();
$db =& DB::object();
if ($db->version() > '4.1') {
$query = $db->query("SHOW FULL COLUMNS FROM " . DB::table($tablename), 'SILENT');
} else {
$query = $db->query("SHOW COLUMNS FROM " . DB::table($tablename), 'SILENT');
}
while ($field = @DB::fetch($query)) {
$data[$field['Field']] = $field;
}
return $data;
}
示例7: _fetch_data
function _fetch_data($block_id)
{
global $_G, $postlist, $config, $authorid, $new_window, $tid, $hott;
$db = DB::object();
$tablepre = $db->tablepre;
$limitforum = $config['disallow_fid'] ? ' AND fid NOT IN (' . dimplode(unserialize($config['disallow_fid'])) . ')' : '';
$limit = $config['show_limit'] > 0 ? $config['show_limit'] : '6';
$show_group = $config['show_group'] ? '' : ' AND isgroup=0';
$date_limit = $config['date_limit'] == 0 ? '' : ' AND dateline>' . ($_G['timestamp'] - $config['date_limit'] * 86400);
$query = DB::query("SELECT tid,highlight,subject FROM {$tablepre}forum_thread WHERE displayorder>-1 {$limitforum}{$date_limit}{$show_group} ORDER BY lastpost DESC LIMIT 0,{$limit}");
while ($thread = DB::fetch($query)) {
$hott_block[] = array('tid' => $thread['tid'], 'link' => "forum.php?mod=redirect&tid={$thread[tid]}&goto=lastpost#lastpost", 'link_info' => $new_window . $this->_sethighlight($thread['highlight']), 'subject' => cutstr($thread['subject'], $config['max_text']));
}
return (array) $hott_block;
}
示例8: create
public function create()
{
global $_G;
//////////////////////////
$fields = "\n\t\t\t`cardnoid` mediumint(8) unsigned NOT NULL auto_increment,\n\t\t\t`cardcatid` smallint(3) NOT NULL,\n\t\t\t`cardpici` smallint(3) NOT NULL,\n\t\t\t`cardno` char(20) character set gbk NOT NULL,\n\t\t\t`cardpass` char(32) character set gbk NOT NULL,\n\t\t\t`cardtype` tinyint(1) NOT NULL,\n\t\t\t`uid` mediumint(8) NOT NULL,\n\t\t\t`status` tinyint(1) NOT NULL,\n\t\t\t`maketime` int(10) unsigned NOT NULL,\n\t\t\t`bindtime` int(10) unsigned NOT NULL,\n\t\t\t`fafanguid` mediumint(8) default NULL,\n\t\t\tPRIMARY KEY (`cardnoid`)\n\t\t";
//////////////////////
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
if (DB::num_rows($query) == 1) {
//DB::query('DROP TABLE '.DB::table($this->_table));
}
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
示例9: _loadsession
function _loadsession($uid, $ip, $checkip = 1)
{
global $_G;
$session = array();
$query = DB::query("SELECT uid, adminid, panel, ip, dateline, errorcount, storage FROM " . DB::table('common_adminsession') . "\n\t\t\tWHERE uid='{$uid}' " . ($checkip ? "AND ip='{$ip}'" : '') . " AND panel='{$this->panel}' AND dateline>'{$this->timelimit}'", 'SILENT');
$db = DB::object();
if (!$db->error()) {
$session = DB::fetch($query);
if (isset($session['storage'])) {
$session['storage'] = $session['storage'] ? unserialize(base64_decode($session['storage'])) : array();
}
} else {
DB::query("DROP TABLE IF EXISTS " . DB::table('common_adminsession') . "");
DB::query("CREATE TABLE " . DB::table('common_adminsession') . " (\n\t\t\t\tuid mediumint(8) UNSIGNED NOT NULL default '0',\n\t\t\t\tadminid smallint(6) unsigned NOT NULL DEFAULT '0',\n\t\t\t\tpanel tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t\tip varchar(15) NOT NULL default '',\n\t\t\t\tdateline int(10) unsigned NOT NULL default '0',\n\t\t\t\terrorcount tinyint(1) NOT NULL default '0',\n\t\t\t\t`storage` mediumtext NOT NULL,\n\t\t\t\tPRIMARY KEY (`uid`, `panel`))" . (mysql_get_server_info() > '4.1' ? " ENGINE=MYISAM DEFAULT CHARSET=" . $_G['config']['db'][1]['dbcharset'] : " TYPE=MYISAM"));
}
return $session;
}
示例10: showcolumns
public function showcolumns($sortid)
{
if (!$sortid) {
return;
}
$sortid = intval($sortid);
$this->_table = 'forum_optionvalue' . $sortid;
$db = DB::object();
if ($db->version() > '4.1') {
$query = DB::query("SHOW FULL COLUMNS FROM %t", array($this->_table), true);
} else {
$query = DB::query("SHOW COLUMNS FROM %t", array($this->_table), true);
}
$tables = array();
while ($field = @DB::fetch($query)) {
$tables[$field['Field']] = 1;
}
return $tables;
}
示例11: create
public function create()
{
global $_G;
$fields = "\n\t\t\t`siteid` smallint(6) NOT NULL auto_increment,\n\t\t\t`siteurl` varchar(255) NOT NULL,\n\t\t\t`salt` char(6) NOT NULL,\n\t\t\t`charset` char(20) NOT NULL,\n\t\t\t`clientip` char(15) NOT NULL,\n\t\t\t`version` char(50) NOT NULL,\n\t\t\t`sitekey` char(32) NOT NULL,\n\t\t\t`sitegroup` text(0) NOT NULL,\n\t\t\t`mokuais` text(0) NOT NULL,\n\t\t\t`installtime` int(10) unsigned NOT NULL,\n\t\t\t`updatetime` int(10) unsigned NOT NULL,\n\t\t\tPRIMARY KEY (`siteid`)\n\t\t";
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
$type = 'debug';
if ($type) {
DB::query('DROP TABLE ' . DB::table($this->_table));
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
} else {
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
}
示例12: create
public function create()
{
global $_G;
$fields = "\n\t\t`mokuaiclassid` mediumint(8) NOT NULL auto_increment,\n\t\t`mokuaiclassname` char(20) NOT NULL,\n\t\t`mokuaiclasstitle` char(40) NOT NULL,\n\t\tPRIMARY KEY (`mokuaiclassid`)\n\t\t";
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
//$type = 'debug';
if ($type) {
DB::query('DROP TABLE ' . DB::table($this->_table));
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
} else {
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
}
示例13: create
public function create()
{
global $_G;
$fields = "\n\t\t\t`mokuaiid` smallint(6) NOT NULL auto_increment,\n\t\t\t`available` tinyint(1) NOT NULL default '0',\n\t\t\t`name` varchar(40) NOT NULL default '',\n\t\t\t`biaoshi` varchar(40) NOT NULL default '',\n\t\t\t`version` varchar(20) NOT NULL default '',\n\t\t\t`displayorder` smallint(6) NOT NULL,\n\t\t\t`price` int(10) NOT NULL,\n\t\t\t`description` varchar(255) NOT NULL,\n\t\t\t`updatetime` int(10) unsigned NOT NULL,\n\t\t\t`createtime` int(10) unsigned NOT NULL,\n\t\t\tPRIMARY KEY (`mokuaiid`)\n\t\t";
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
//$type = 'debug';
if ($type) {
DB::query('DROP TABLE ' . DB::table($this->_table));
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
} else {
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
}
示例14: siteinformation
function siteinformation()
{
global $_G, $siteuniqueid, $save_mastermobile, $save_masterqq, $save_masteremail;
$db = DB::object();
$update = array('uniqueid' => $siteuniqueid, 'version' => DISCUZ_VERSION, 'release' => DISCUZ_RELEASE, 'php' => PHP_VERSION, 'mysql' => $db->version(), 'charset' => CHARSET, 'bbname' => $_G['setting']['bbname'], 'mastermobile' => $save_mastermobile, 'masterqq' => $save_masterqq, 'masteremail' => $save_masteremail, 'software' => $_SERVER['SERVER_SOFTWARE'], 'my_siteid' => $_G['setting']['my_siteid'], 'my_sitekey' => $_G['setting']['my_sitekey']);
$updatetime = @filemtime(DISCUZ_ROOT . './data/updatetime.lock');
if (empty($updatetime) || TIMESTAMP - $updatetime > 3600 * 4) {
@touch(DISCUZ_ROOT . './data/updatetime.lock');
$tableprelen = strlen($db->tablepre);
$table = array('forum_thread' => 'threads', 'forum_post' => 'posts', 'forum_attachment' => 'fattachments', 'common_member' => 'members', 'home_album' => 'albums', 'home_blog' => 'blogs', 'home_doing' => 'doings', 'home_poke' => 'pokes', 'home_share' => 'shares', 'portal_topic' => 'topics', 'portal_article_title' => 'articles', 'portal_attachment' => 'pattachments');
foreach (C::t('common_setting')->fetch_all_table_status() as $row) {
$tablename = substr($row['Name'], $tableprelen);
if (!isset($table[$tablename])) {
continue;
}
$update[$table[$tablename]] = $row['Rows'];
}
foreach (C::t('forum_thread')->count_special_group_by_special() as $thread) {
$thread['special'] = intval($thread['special']);
$update['spt_' . $thread['special']] = $thread['spcount'];
}
$update['groups'] = C::t('forum_forum')->fetch_forum_num('group');
$update['forums'] = C::t('forum_forum')->fetch_forum_num();
$update['adminemail'] = $_G['setting']['adminemail'];
if ($_G['setting']['msn']['on'] && $_G['setting']['msn']['domain']) {
$update['msn_domain'] = $_G['setting']['msn']['domain'];
}
$comma = '';
foreach (C::t('common_patch')->fetch_patch_by_status(array(1, 2)) as $patch) {
$update['patch'] .= $comma . $patch['serial'];
$comma = ',';
}
}
$data = '';
foreach ($update as $key => $value) {
$data .= $key . '=' . rawurlencode($value) . '&';
}
return 'os=dx&update=' . rawurlencode(base64_encode($data)) . '&md5hash=' . substr(md5($_SERVER['HTTP_USER_AGENT'] . implode('', $update) . TIMESTAMP), 8, 8) . '×tamp=' . TIMESTAMP;
}
示例15: create
public function create()
{
global $_G;
//////////////////////////
$fields = "\n\t\t\t`jiashizhengid` smallint(6) NOT NULL auto_increment,\n\t\t\t`jiashizhengname` varchar(40) NOT NULL default '',\n\t\t\t`jiashizhengtitle` varchar(40) NOT NULL default '',\n\t\t\t`jiashizhengsort` varchar(40) NOT NULL default '',\n\t\t\t`jiashizhengimages` varchar(40) NOT NULL default '',\n\t\t\t`description` text NOT NULL,\n\t\t\t`status` tinyint(1) NOT NULL default '0',\n\t\t\t`createtime` int(10) unsigned NOT NULL,\n\t\t\t`updatetime` int(10) unsigned NOT NULL,\n\t\t\tPRIMARY KEY (`jiashizhengid`)\n\t\t";
//////////////////////
$query = DB::query("SHOW TABLES LIKE '%t'", array($this->_table));
//$type = 'debug';
if ($type) {
DB::query('DROP TABLE ' . DB::table($this->_table));
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
} else {
if (DB::num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE " . DB::table($this->_table) . " ({$fields}) TYPE=MyISAM;";
$db = DB::object();
$create_table_sql = $this->syntablestruct($create_table_sql, $db->version() > '4.1', $_G['config']['db']['1']['dbcharset']);
DB::query($create_table_sql);
}
}
}