标签:insert name 表名 and 数组 use sel man pre
加载对象: 在控制器中 use yii\db\Query;
$query=new Query();
查询多条:$arr=$query->select(‘*‘)->from(‘register‘)->where("username=‘jiahaiyong‘")->all();
查询单条:$arr=$query->select(‘*‘)->from(‘register‘)->where("username=‘jiahaiyong‘")->one();
限制条数:$query->limit(10);
两表联查:$query->select([‘user.name AS author‘, ‘post.title as title‘])->from(‘user‘)->leftJoin(‘post‘, ‘post.user_id = user.id‘);
修改:eg: $res=Yii::$app-db->createCommand()->update(‘表名‘, 修改数组, " id = $id ")->execute();
删除:eg:$res=Yii::$app->db->createCommand()->delete(‘表名‘, "id = $id条件")->execute();
添加eg:$res= Yii::$app->db->createCommand()->insert(‘表名‘,插入的数组)->execute();
标签:insert name 表名 and 数组 use sel man pre
原文地址:http://www.cnblogs.com/zhanghuilong/p/6365712.html