本文整理汇总了PHP中DB::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::num_rows方法的具体用法?PHP DB::num_rows怎么用?PHP DB::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::num_rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WriteMenu
function WriteMenu($siteid, $siteurl, $sitetarget, $a, $Display, $AdminDisplay)
{
$DbLink2 = new DB();
$DbLink2->query("SELECT id,url,target FROM " . C_PAGE_TBL . " Where parent = '" . cleanQuery($siteid) . "' and active='1' and ((display='{$Display}') or (display='2') " . $AdminDisplay . ") ORDER BY rank ASC ");
if ($siteurl != "") {
if ($sitetarget == '_self') {
if ($_GET[btn] == $siteid) {
echo "<li><a href=\"#\"><span>{$a[$siteid]}</span></a>";
if ($DbLink2->num_rows() > 0) {
echo "<ul>";
while (list($siteid2, $siteurl2, $sitetarget2) = $DbLink2->next_record()) {
WriteMenu($siteid2, $siteurl2, $sitetarget2, $a, $Display, $AdminDisplay);
}
echo "</ul>";
}
echo "</li>";
} else {
echo "<li><a href=\"{$siteurl}&btn={$siteid}\"><span>{$a[$siteid]}</span></a>";
if ($DbLink2->num_rows() > 0) {
echo "<ul>";
while (list($siteid2, $siteurl2, $sitetarget2) = $DbLink2->next_record()) {
WriteMenu($siteid2, $siteurl2, $sitetarget2, $a, $Display, $AdminDisplay);
}
echo "</ul>";
}
echo "</li>";
}
} else {
if ($sitetarget == '_external') {
echo "<li><a href=\"{$siteurl}\"><span>{$a[$siteid]}</span></a>";
if ($DbLink2->num_rows() > 0) {
echo "<ul>";
while (list($siteid2, $siteurl2, $sitetarget2) = $DbLink2->next_record()) {
WriteMenu($siteid2, $siteurl2, $sitetarget2, $a, $Display, $AdminDisplay);
}
echo "</ul>";
}
echo "</li>";
} else {
echo "<li><a href=\"#\" onclick=\"window.open('{$siteurl}','mywindow','')\"><span>{$a[$siteid]}</span></a>";
if ($DbLink2->num_rows() > 0) {
echo "<ul>";
while (list($siteid2, $siteurl2, $sitetarget2) = $DbLink2->next_record()) {
WriteMenu($siteid2, $siteurl2, $sitetarget2, $a, $Display, $AdminDisplay);
}
echo "</ul>";
}
echo "</li>";
}
}
} else {
echo "<li><a href=\\index.php?&page=smodul&id={$siteid}&btn={$siteid}\"><span>{$a[$siteid]}</span></a></li>";
}
}
示例2: my_member_validate
function my_member_validate($uid, $email, $role_id = '', $new = 0, $check_allow = 1)
{
if (1 > ($uid = (int) $uid)) {
return false;
}
if (!($email = trim($email))) {
return false;
}
$sys_config = jconf::get();
if ($new == 0 && !$sys_config['reg_email_verify']) {
return false;
}
if ($check_allow && jdisallow($uid)) {
return false;
}
$sql = "select * from `" . TABLE_PREFIX . "member_validate` where `uid`='{$uid}' order by `regdate` asc";
$query = DB::query($sql);
$data = array();
if (DB::num_rows($query) > 0) {
DB::query("delete from `" . TABLE_PREFIX . "member_validate` where `uid`='{$uid}'");
}
$data['uid'] = $uid;
$data['email'] = $email;
$data['role_id'] = (int) ($role_id > 0 ? $role_id : $sys_config['normal_default_role_id']);
$data['key'] = substr(md5(md5($uid . $email . $role_id) . md5(uniqid(mt_rand(), true))), 3, 16);
$data['status'] = $data['verify_time'] = '0';
$data['regdate'] = TIMESTAMP;
$data['type'] = 'email';
jtable('member_validate')->insert($data);
$email_message = "您好:\r\n您收到此邮件是因为在 {$sys_config['site_url']} 用户注册中使用了该 Email,\r\n如果您没有进行上述操作,请忽略这封邮件。\r\n------------------------------------------------------\r\n帐号激活说明:\r\n为避免垃圾邮件或您的Email地址被滥用,我们需要对您的email有效性进行验证,\r\n您只需点击下面的链接即可激活您的帐号,并享有真正会员权限:\r\n{$sys_config['site_url']}/index.php?mod=member&code=verify&uid={$data['uid']}&key={$data['key']}&from=reg\r\n\r\n(如果上面不是链接形式,请将地址手工粘贴到浏览器地址栏再访问)\r\n感谢您的访问,祝您使用愉快!\r\n\r\n此致,\r\n{$sys_config['site_name']} 管理团队.\r\n";
$send_result = send_mail($email, " [{$sys_config['site_name']}]Email地址验证", $email_message, $sys_config['site_name'], $sys_config['site_admin_email'], array(), 3, false);
return $send_result;
}
示例3: piclens_gallery
function piclens_gallery()
{
$item_id = EClassApi::getParam('item_id');
$entry = '';
if ($item_id) {
$sql = 'select id, original_image_url, title, position from item_image where item_id = ' . intval($item_id) . ' ORDER BY position ';
DB::query($sql);
if (DB::num_rows()) {
$entry = '';
while ($rows = DB::fetch_row()) {
$rows['title'] = $rows['title'] ? $rows['title'] : "Image {$rows['position']}";
$rows['title'] = trim(XMLLib::_xml_encode_attribute($rows['title']));
if (ereg('/', $rows['original_image_url'])) {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "{$rows['original_image_url']}"));
} else {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "uploaded/items/{$rows['original_image_url']}"));
}
$entry .= "\n\t\t \t \t<item>\n\t\t \t \t\t\t<title>" . stripslashes($rows['title']) . "</title>\n\t\t\t\t\t\t<link>{$url}</link>\n\t\t\t\t\t\t<guid>Image {$rows['position']}</guid>\n\t\t\t\t\t\t<media:thumbnail url=\"{$url}\" />\n\t\t\t\t\t\t<media:content url=\"{$url}\" />\n\t\t\t\t</item>\n\t\t \t \t";
}
@header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\t\t\t <rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">\n\t\t\t <channel>\t\t\t\n\t\t\t <title>Enbac.com</title>\n\t\t\t <link>http://www.chonmon.vn/</link>\n\t\t\t <description>Enbac.com - </description>\n\t\t\t <logo url=\"style/images/logo.piclens.png\" />\n\t\t\t";
echo $entry;
echo "\n\t\t \t </channel>\n\t\t\t </rss>\n\t\t\t";
} else {
die("no_info");
}
} else {
die("no_info");
}
}
示例4: update
public function update($id, $name, $teacherId, $year, $month, $imgFileName, $videoFileName, $content, $uploadTime) {
$query = DB::query('select * from '.DB::table('book_video').' where year='.$year.' and month='.$month.' and id <> '.$id);
if(DB::num_rows($query) > 0) {
return "视频信息修改失败,存在".$year."年".$month."月的视频!";
} else {
//当前时间
$time = date("Y-m-d H:i:s");
DB::update( $this->_table,
array(
'name' => $name,
'teacherId' => $teacherId,
'year' => $year,
'month' => $month,
'imgFileName' => $imgFileName,
'videoFileName' => $videoFileName,
'content' => $content,
'uploadTime' => $uploadTime,
'updateTime' => $time
),
array('id'=> $id)
);
return "视频信息修改成功!";
}
}
示例5: 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);
}
}
}
示例6: flash_view_gallery
function flash_view_gallery()
{
$user_id = (int) Url::get('user_id');
if ($user_id) {
$sql = 'select id, original_image_url, des FROM item_image WHERE user_id = ' . $user_id . ' AND root_id=0 ORDER BY id DESC LIMIT 0,200';
DB::query($sql);
if (DB::num_rows()) {
$entry = '';
while ($rows = DB::fetch_row()) {
$rows['des'] = $rows['des'] ? $rows['des'] : "Image {$rows['id']}";
$rows['des'] = trim(XMLLib::_xml_encode_attribute($rows['des']));
if (eregi('/', $rows['original_image_url'])) {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "{$rows['original_image_url']}"));
} else {
$url = trim(XMLLib::_xml_encode_attribute("http://" . IMAGE_PATH . "uploaded/items/{$rows['original_image_url']}"));
}
$entry .= "\n\t\t\t\t\t\t\t<photo imageurl=\"{$url}\" linkurl=\"http://chonmon.vn\">\n\t\t\t\t\t\t\t\t<title>{$rows['des']}</title>\n\t\t\t\t\t\t\t</photo>\t\t \t \t\n\t\t\t\t \t \t";
}
@header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?" . '>';
echo "<tiltviewergallery><photos>";
echo $entry;
echo "</photos></tiltviewergallery>";
} else {
die("no_info");
}
} else {
die("no_info");
}
}
示例7: update
public function update($id, $name, $code) {
$query = DB::query('select * from '.DB::table('book_college').' where (name=\''.$name.'\' or code=\''.$code.'\') and id<>'.$id);
if(DB::num_rows($query) > 0) {
return "学院修改失败,存在同名或者同代号的学院!";
} else {
DB::update($this->_table, array('name'=>$name,'code'=>$code), array('id'=> $id));
return "学院修改成功!";
}
}
示例8: build_cache_smilies_js
function build_cache_smilies_js()
{
global $_G;
$query = DB::query("SELECT typeid, name, directory FROM " . DB::table('forum_imagetype') . " WHERE type='smiley' AND available='1' ORDER BY displayorder");
$fastsmiley = (array) unserialize(DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='fastsmiley'"));
$return_type = 'var smilies_type = new Array();';
$return_array = 'var smilies_array = new Array();var smilies_fast = new Array();';
$spp = $_G['setting']['smcols'] * $_G['setting']['smrows'];
$fpre = '';
while ($type = DB::fetch($query)) {
$return_data = array();
$return_datakey = '';
$squery = DB::query("SELECT id, code, url FROM " . DB::table('common_smiley') . " WHERE type='smiley' AND code<>'' AND typeid='{$type['typeid']}' ORDER BY displayorder");
if (DB::num_rows($squery)) {
$i = 0;
$j = 1;
$pre = '';
$return_type .= 'smilies_type[\'_' . $type['typeid'] . '\'] = [\'' . str_replace('\'', '\\\'', $type['name']) . '\', \'' . str_replace('\'', '\\\'', $type['directory']) . '\'];';
$return_datakey .= 'smilies_array[' . $type['typeid'] . '] = new Array();';
while ($smiley = DB::fetch($squery)) {
if ($i >= $spp) {
$return_data[$j] = 'smilies_array[' . $type['typeid'] . '][' . $j . '] = [' . $return_data[$j] . '];';
$j++;
$i = 0;
$pre = '';
}
if ($size = @getimagesize(DISCUZ_ROOT . './static/image/smiley/' . $type['directory'] . '/' . $smiley['url'])) {
$smiley['code'] = str_replace('\'', '\\\'', $smiley['code']);
$smileyid = $smiley['id'];
$s = smthumb($size, $_G['setting']['smthumb']);
$smiley['w'] = $s['w'];
$smiley['h'] = $s['h'];
$l = smthumb($size);
$smiley['lw'] = $l['w'];
unset($smiley['id'], $smiley['directory']);
$return_data[$j] .= $pre . '[\'' . $smileyid . '\', \'' . $smiley['code'] . '\',\'' . str_replace('\'', '\\\'', $smiley['url']) . '\',\'' . $smiley['w'] . '\',\'' . $smiley['h'] . '\',\'' . $smiley['lw'] . '\']';
if (is_array($fastsmiley[$type['typeid']]) && in_array($smileyid, $fastsmiley[$type['typeid']])) {
$return_fast .= $fpre . '[\'' . $type['typeid'] . '\',\'' . $j . '\',\'' . $i . '\']';
$fpre = ',';
}
$pre = ',';
}
$i++;
}
$return_data[$j] = 'smilies_array[' . $type['typeid'] . '][' . $j . '] = [' . $return_data[$j] . '];';
}
$return_array .= $return_datakey . implode('', $return_data);
}
$cachedir = DISCUZ_ROOT . './data/cache/';
if (@($fp = fopen($cachedir . 'common_smilies_var.js', 'w'))) {
fwrite($fp, 'var smthumb = \'' . $_G['setting']['smthumb'] . '\';' . $return_type . $return_array . 'var smilies_fast=[' . $return_fast . '];');
fclose($fp);
} else {
exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
}
}
示例9: fetch_list_by_search
public function fetch_list_by_search($condition, $orders = '', $type = 0, $start = 0, $limit = 0)
{
if ($type == 1) {
$result = DB::fetch_all("SELECT * FROM %t WHERE 1%i {$orders} LIMIT {$start},{$limit}", array($this->_table, $condition));
} else {
$n = DB::query("SELECT * FROM " . DB::table($this->_table) . " WHERE 1{$condition} {$orders}");
$result = DB::num_rows($n);
}
return $result;
}
示例10: getmagic
function getmagic($magicid, $magicnum, $weight, $totalweight, $uid, $maxmagicsweight, $force = 0)
{
if ($weight + $totalweight > $maxmagicsweight && !$force) {
showmessage('magics_weight_range_invalid', '', array('less' => $weight + $totalweight - $maxmagicsweight));
} else {
$query = DB::query("SELECT magicid FROM " . DB::table('common_member_magic') . " WHERE uid='{$uid}' AND magicid='{$magicid}'");
if (DB::num_rows($query)) {
DB::query("UPDATE " . DB::table('common_member_magic') . " SET num=num+'{$magicnum}' WHERE uid='{$uid}' AND magicid='{$magicid}'");
} else {
DB::query("INSERT INTO " . DB::table('common_member_magic') . " (uid, magicid, num) VALUES ('{$uid}', '{$magicid}', '{$magicnum}')");
}
}
}
示例11: create
public function create($sortid, $fields, $dbcharset)
{
if (!$sortid || !$fields || !$dbcharset) {
return;
}
$sortid = intval($sortid);
$this->_table = 'forum_optionvalue' . $sortid;
$query = DB::query("SHOW TABLES LIKE '%t'", array($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', $dbcharset);
DB::query($create_table_sql);
}
}
示例12: build_cache_smileycodes
function build_cache_smileycodes()
{
$data = array();
$query = DB::query("SELECT typeid, directory FROM " . DB::table('forum_imagetype') . " WHERE type='smiley' AND available='1' ORDER BY displayorder");
while ($type = DB::fetch($query)) {
$squery = DB::query("SELECT id, code, url FROM " . DB::table('common_smiley') . " WHERE type='smiley' AND code<>'' AND typeid='{$type['typeid']}' ORDER BY displayorder");
if (DB::num_rows($squery)) {
while ($smiley = DB::fetch($squery)) {
if ($size = @getimagesize('./static/image/smiley/' . $type['directory'] . '/' . $smiley['url'])) {
$data[$smiley['id']] = $smiley['code'];
}
}
}
}
save_syscache('smileycodes', $data);
}
示例13: build_cache_ipbanned
function build_cache_ipbanned()
{
DB::query("DELETE FROM " . DB::table('common_banned') . " WHERE expiration<'" . TIMESTAMP . "'");
$data = array();
$query = DB::query("SELECT ip1, ip2, ip3, ip4, expiration FROM " . DB::table('common_banned'));
if (DB::num_rows($query)) {
$data['expiration'] = 0;
$data['regexp'] = $separator = '';
}
while ($banned = DB::fetch($query)) {
$data['expiration'] = !$data['expiration'] || $banned['expiration'] < $data['expiration'] ? $banned['expiration'] : $data['expiration'];
$data['regexp'] .= $separator . ($banned['ip1'] == '-1' ? '\\d+\\.' : $banned['ip1'] . '\\.') . ($banned['ip2'] == '-1' ? '\\d+\\.' : $banned['ip2'] . '\\.') . ($banned['ip3'] == '-1' ? '\\d+\\.' : $banned['ip3'] . '\\.') . ($banned['ip4'] == '-1' ? '\\d+' : $banned['ip4']);
$separator = '|';
}
save_syscache('ipbanned', $data);
}
示例14: create
public function create()
{
global $_G;
//////////////////////////
$fields = "\n\t\t\t`cardcatid` smallint(6) unsigned NOT NULL auto_increment,\n\t\t\t`cardcatname` char(50) character set gbk NOT NULL,\n\t\t\t`cardcatdescription` text character set gbk NOT NULL,\n\t\t\t`cardjine` int(10) unsigned NOT NULL,\n\t\t\t`cardpice` int(10) unsigned NOT NULL,\n\t\t\t`cardyouxiaoqi` int(10) unsigned NOT NULL,\n\t\t\t`carddzyouxiaoqi` char(10) character set gbk NOT NULL,\n\t\t\t`status` tinyint(1) NOT NULL,\n\t\t\t`cardcatico` varchar(255) character set gbk NOT NULL,\n\t\t\t`cardkaishi` int(10) unsigned NOT NULL,\n\t\t\t`cardtype` char(20) character set gbk NOT NULL,\n\t\t\t`cardjifen` int(10) NOT NULL,\n\t\t\t`cardqingling` varchar(255) character set gbk NOT NULL,\n\t\t\t`shopid` mediumint(8) NOT NULL,\n\t\t\tPRIMARY KEY (`cardcatid`)\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);
}
}
示例15: sqldumptable
function sqldumptable($table, $startfrom = 0, $currsize = 0)
{
//备分当前表的所有数据
global $_G, $startrow;
$offset = 10000;
$size = 1024;
$tabledump = '';
$tablefields = array();
$query = DB::query("SHOW FULL COLUMNS FROM {$table}", 'SILENT');
while ($fieldrow = DB::fetch($query)) {
$tablefields[] = $fieldrow;
}
$tabledumped = 0;
$numrows = $offset;
$firstfield = $tablefields[0];
while ($currsize + strlen($tabledump) + 500 < $size * 1000 && $numrows == $offset) {
//$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $startfrom ORDER BY $firstfield[Field] LIMIT $offset"; //主键大于0
$selectsql = "SELECT * FROM {$table} ORDER BY {$firstfield['Field']} LIMIT {$offset}";
$tabledumped = 1;
$rows = DB::query($selectsql);
$numfields = $this->db->num_fields($rows);
$numrows = DB::num_rows($rows);
while ($row = $this->db->fetch_row($rows)) {
$comma = $t = '';
for ($i = 0; $i < $numfields; $i++) {
$t .= '\'' . mysql_escape_string($row[$i]) . '\',';
$comma = ',';
}
$t = trim($t, ',');
if (strlen($t) + $currsize + strlen($tabledump) + 500 < $size * 1000) {
if ($firstfield['Extra'] == 'auto_increment') {
$startfrom = $row[0];
} else {
$startfrom++;
}
$tabledump .= "INSERT INTO {$table} VALUES ({$t});\n";
} else {
$complete = FALSE;
break 2;
}
}
}
$startrow = $startfrom;
$tabledump .= "\n";
return $tabledump;
}