高手过来看看!
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Users;
class IndexController extends Controller{
public function actionIndex(){
//查询数据
$sql = 'select * from users where id=1'; //一会儿将改这里
$results=Users::findBySql($sql)->all();
print_r($results);
}
}
查询一次数据库中users表后,删掉users表,新建一个users1表,将上述代码改为
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Users;
class IndexController extends Controller{
public function actionIndex(){
//查询数据
$sql = 'select * from users1 where id=1'; //这里做了改动
$results=Users::findBySql($sql)->all();
print_r($results);
}
}
刷新页面为什么提示
Invalid Configuration – yii\base\InvalidConfigException
The table does not exist: {{%users}}
我明明要查询users1了呀,为什么还查询之前的users?