thinkphp 数据库操作
//所有的数据中,查出某个字段
$result = $music->field('music')->select();
$hotlist = M('News')->where('status=1')->field('id,title')->order('views desc')->limit(6)->select();
//根据条件查询
$result = $music->where()->order()->select();
//查单条单个单个
$result = $music->field('music')->getField('id,name');
//查单条
$result = $music->where()->find();
//模糊查询
$result = $user->where(" 1 and (title like '%" .$name. "%') or (content like '%" .$name. "%') ")->select();
$result = $user->where(" 1 and ( username like '{$name}' or number like '{$name}')")->find();
//添加
$result = $user->data($data)->add();
//修改
$result = $user->where("number={$_POST['number']}")->save($data);
//删除
$result = $user->where("id={$_POST['id']}")->delete();
//数量自加一
$user->where("id=$_POST['id']")->setInc('call');
//根据条件排序 优先问题
$sql2 = "select u.id,u.scall,sum(b.all_time) as all_time from it_userinfo u left join it_bookaudio b on b.userid = u.id group by u.id order by u.scall desc,sum(b.all_time) desc";
SELECT day,luying FROM daka WHERE 1=1 AND day >= (UNIX_TIMESTAMP('2018-03-01')) AND day < (UNIX_TIMESTAMP('2018-03-31')) GROUP BY day,ORDER BY day desc