discuz数据库

2021-03-20 822 0条评论

image.png


//插入一条数据

Db::insert('test',array('name'=>'51zuso'),true);

//如果存在则更新

Db::insert('test',array('id'=>1,'name'=>'51zuso_1'),true,true);


image.png

//删除

Db::delete('test','id>1',1,true)



image.png


image.png


$id= 1;

$data = DB::fetch_first('SELECT * FROM %t WHERE id=%d',array(

'test',$id

));

debug($data)


image.png

$data = DB::fetch_all('SELECT * FROM %t WHERE id>=%d AND id<=%d',array(

'test',1,5

));


id为key值

$data = DB::fetch_all('SELECT * FROM %t WHERE id>=%d AND id<=%d',array(

'test',1,5

),'id');

debug($data)

image.png


echo DB::result_first('SELECT MAX(id) FROM %t',array(

'test'

));



image.png




image.png

$data = DB::query('SELECT * FROM %t WHERE id IN(%n)',array(

'test',array(1,2,3)

));


while($res = DB::fetch($data)){

$result[] = $res;

}


debug($result)



image.png


$query = DB::query('SELECT name FROM %t WHERE id > %d',array(

'test',1

));


$data = DB::result($query,0);


debug($data)



$query = DB::query('SELECT count(*) FROM %t WHERE id > %d',array(

'test',1

));


$data = DB::result($query,0);


image.png


$query = DB::query('SELECT count(*) FROM %t WHERE id > %d',array(

'test',1

));

$data = DB::result($query);


DB::free_result($query);


image.png

$query = DB::query('SELECT * FROM %t WHERE id > %d ORDER BY'.DB::order('id','DESC'),array(

'test',1

));


while($res = DB::fetch($query)){

$result[] = $res;

}

debug($result);



image.png



$query = DB::query('SELECT * FROM %t WHERE id > %d ORDER BY'.DB::order('id','DESC').DB::limit(0,3),array(

'test',1

));


while($res = DB::fetch($query)){

$result[] = $res;

}

debug($result);


image.png

$f = DB::implode(array('id'=>10,'name'=>'qqq'),'and');

debug($f);


echo DB::query('UPDATE %t SET'.DB::implode(array(

'name'=>'51zu'

)).' WHERE id=%d',array(

'test',1

));



image.png


echo DB::field('a',111,'=');



文章版权及转载声明

本文作者:符文浩 网址:http://blog.fuwenhao.com/post/409.html 发布于 2021-03-20
文章转载或复制请以超链接形式并注明出处。

发表评论

快捷回复:

评论列表 (暂无评论,822人围观)参与讨论

还没有评论,来说两句吧...

取消
微信二维码
微信二维码
支付宝二维码