时间:2021-07-01 10:21:17 帮助过:4人阅读
根据id查询一条数据,并对id进行过滤:
$id = 1;
$result = Yii::$app->db->createCommand("select * from product where id=:id")->bindParam(":id",$id,\PDO::PARAM_INT)->queryAll();
$result = Yii::$app->db->createCommand("select * from product where id=:id")->bindParam(":id",$id,\PDO::PARAM_STR)->queryAll();更新一条数据:
$id = 1;
$name = 'xiaoming';
$result = Yii::$app->db->createCommand("update product set name=:name where id=:id")->
bindParam(':id',$id,\PDO::PARAM_INT)->bindParam(':name',$name,\PDO::PARAM_INT)->execute();以下写法在会报错
$result = Yii::$app->db->createCommand()->delete('product',
['name'=>':value'],'id=:id')->bindValue(':id',1,\PDO::PARAM_INT)->
bindParam(':value',$user,\PDO::PARAM_INT)->execute();相关推荐:
php pdo中PDOStatement 类的bindParam和bindValue方法的区别
以上就是bindParam和bindValue的区别详解的详细内容,更多请关注Gxl网其它相关文章!