标签:set 命名 url delete int nbsp pid http 推荐
//thinkphp的原生查询
$sql = "select pid,url from destoon_ad where aid>3";
$result = Db::query($sql);
dump($result);
------------------------------------------------------------
参数绑定
$sql = "select pid,url from destoon_ad where aid>?";
$result = Db::query($sql,[3]);
------------------------------------------------------------
命名点位符绑定【推荐】
$sql = "select pid,url from destoon_ad where aid>:aid";
$result = Db::query($sql,[‘aid‘=>3]);
------------------------------------------------------------
//更新操作
$sql = ‘update destoon_ad set hits=hits+100 where aid=:aid‘;
$result = Db::execute($sql,[‘aid‘=>3]);
------------------------------------------------------------
//新增操作
$sql = ‘insert into destoon_ad (pid,url,hits) value (:pid,:url,:hits)‘;
$result = Db::execute($sql,[‘pid‘=>10,‘url‘=>‘www.baidu.com‘,‘hits‘=>1000]);
------------------------------------------------------------
//删除操作
$sql = ‘delete from destoon_ad where pid=:pid‘;
$result = Db::execute($sql,[‘pid‘=>10]);
标签:set 命名 url delete int nbsp pid http 推荐
原文地址:https://www.cnblogs.com/my2018/p/8836717.html