AB亚博体育平台官网vip入口网:专注于dede亚博体育平台官网vip入口,织梦源码,织梦亚博体育平台官网vip入口,网站亚博体育平台官网vip入口,dedecms亚博体育平台官网vip入口,网站源码,dedecms教程以及各类手机网站亚博体育平台官网vip入口和企业网站亚博体育平台官网vip入口分享.
用户名:
密码:
注册

织梦亚博体育平台官网vip入口

VIP

discuz 如何添加数据DB::insert和更新数据DB::update 查询DB::qu

www.adminbuy.cn / 2014-12-18
1.添加数据DB::insert
$uid=empty($_POST['uid']) ? "" : $_POST['uid'];
$username=empty($_POST['username']) ? "" : $_POST['username'];
$display_type=empty($_POST['display_type']) ? "" : $_POST['display_type'];
$filename=empty($_POST['filename']) ? "" : $_POST['filename'];?
$details=empty($_POST['details']) ? "" : $_POST['details'];
$videoname=empty($_POST['videoname']) ? "" : $_POST['videoname'];
//$sql="insert into pre_home_video(uid,display_type,filename,default) values('$uid','$display_type','$filename','$default')";
//$query = DB::query($sql);
if(!empty($_POST['uid']) && !empty($_POST['display_type']) && !empty($_POST['display_type'] ))
{
$count = DB::result(DB::query("select uid from pre_common_member where uid= $uid"), 0);
if($count)
{
$arr=array();
$arr['uid'] = $uid;
$arr['username'] = $username;
$arr['display_type'] = $display_type;
$arr['filename'] = $filename;?
$arr['details'] = $details;
$arr['videoname'] = $videoname;
if(!file_exists("data/video/{$uid}")){
mkdir("data/video/{$uid}", 0700);
}
if(!file_exists("data/video/{$uid}/cover")){
mkdir("data/video/{$uid}/cover", 0700);
}
$count1=DB::insert('home_video',$arr);
if($count1)
{
echo("");
?
}
}
else
{
echo("");
}
更新
$id = $_GET['id'] ? $_GET['id'] : 0;
$query = DB::query("select * from ".DB::table('home_hall')." where id=$id");
if($query){
$data = DB::fetch($query);
if($type == 'gold'){
if($op == 'add'){
$data['isgold'] = 1;
}elseif($op = 'cancle'){
$data['isgold'] = 0;
}
DB::update('home_hall', array('isgold'=>$data['isgold']),array('id'=> $id));
}elseif($type == 'index'){
if($op == 'add'){
$data['isindex'] = 1;
}elseif($op = 'cancle'){
$data['isindex'] = 0;
}
DB::update('home_hall', array('isindex'=>$data['isindex']),array('id'=> $id));
}
}else{
echo '没有此展厅';
}
3.查询,返回结果集
$perpage = 25;
$start = ($page-1)*$perpage;
$mpurl = ADMINSCRIPT.'?action=goldhall';
$count = DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table('home_hall')), 0);
if($count){
$query = DB::query("SELECT * FROM ".DB::table('home_hall')." limit $start, $perpage");
while ($value = DB::fetch($query)) {
$list[] = $value;
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
?
echo '';
echo '用户id展厅名展厅级别联系电话操作操作';
foreach ($list as $k => $v){
echo "";
echo "{$v['uid']}";
echo "{$v['hallname']}";
echo $v['isgold'] ? "金牌" : "普通";
echo "{$v['telephone']}";
if($v['isgold'] == 1){
}else{
echo "升级";
}
if($v['isindex'] == 1){
}else{
echo "首页推荐";
}
echo "";
}
echo '';
if($multipage){
echo $multipage;
}?
//删除
if($_GET['op'] == 'delete'){
if($gid){ //还要删除文件
DB::delete('saige_geku', array('id' => $gid));
DB::delete('saige_gekufield', array('gid' => $gid));
DB::delete('saige_gkcomment', array('gid' => $gid));
}
?
}
本文由AB亚博体育平台官网vip入口网:织梦亚博体育平台官网vip入口整理发布,转载请说明出处:http://www.adminbuy.cn
首页 亚博体育平台官网vip入口 亚博官网登录 会员中心
收缩