时间:2021-07-01 10:21:17 帮助过:12人阅读
insert
$row = Yii::app()->getDb()->createCommand()->insert('goods', array( 'good_name' => $goods_name, 'good_type' => $goods_type, 'price' => $price, 'buy_nums' => 0, 'commit_nums' => 0, 'create_time' => time(), ));
单表查询
$goodsTypes = Yii::app()->getDb()->createCommand() ->select('type_id, type_name') ->from('goods_type') ->where('status=1')->queryAll();
$goods = Yii::app()->getDb()->createCommand()->from('goods g') ->select('g.good_id, g.good_name, gt.type_name, g.price, g.buy_nums, g.commit_nums, g.create_time') ->join('goods_type gt', 'g.good_type=gt.type_id') ->where('g.`status`=1 and gt.`status`=1') ->order('g.create_time desc') ->queryAll();
$row = Yii::app()->getDb()->createCommand() ->delete('goods', "good_id='{$goods_id}'");
$row = Yii::app()->getDb()->createCommand()->update('goods', array( 'good_name' => $goods_name, 'good_type' => $goods_type, 'price' => $price, ), "good_id='{$goods_id}'");
就记录这点吧~
以上就介绍了Yii createCommand CURD操作,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。