//插入一条数据
Db::insert('test',array('name'=>'51zuso'),true);
//如果存在则更新
Db::insert('test',array('id'=>1,'name'=>'51zuso_1'),true,true);
//删除
Db::delete('test','id>1',1,true)
$id= 1;
$data = DB::fetch_first('SELECT * FROM %t WHERE id=%d',array(
'test',$id
));
debug($data)
$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)
echo DB::result_first('SELECT MAX(id) FROM %t',array(
'test'
));
$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)
$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);
$query = DB::query('SELECT count(*) FROM %t WHERE id > %d',array(
'test',1
));
$data = DB::result($query);
DB::free_result($query);
$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);
$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);
$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
));
echo DB::field('a',111,'=');
还没有评论,来说两句吧...