$re=Yii::$app->db->createCommand()->insert('table', [
'name' => 'Sam',
'age' => 30,])->execute();
echo "$re";
die;
//返回影响的条数
插入多条
$re=Yii::$app->db->createCommand()->batchInsert('table', ['name', 'age'], [
['Tom', 30],
['Jane', 20],
['Linda', 25],
])->execute();
echo "$re";
die;
//返回影响的条数
改
$re=Yii::$app->db->createCommand()->update('table', ['name' => 'xinzhi'], 'id=3')->execute();
echo "$re";die;
//返回影响的条数
//删
$re=Yii::$app->db->createCommand()->delete('table', 'id=1')->execute();
echo "$re";die;
//返回影响的条数
//批删
$re=Yii::$app->db->createCommand()->delete('table', 'id in(1,2,3)')->execute();
echo "$re";die;
//返回影响的条数
查询全部
$post = Yii::$app->db->createCommand("SELECT * FROM table")
->queryAll();
print_r($post);die;
//返回查到的信息
//查询单条信息
//查询单条
$post = Yii::$app->db->createCommand("SELECT * FROM table WHERE id=1")
->queryOne();
print_r($post);die;