課程
/后端開發
/PHP
/Yii框架不得不說的故事—基礎篇(1)
使用php yii 框架,第一次用php代碼查詢Mysql中的表后,修改php代碼,想要查詢另一張表,可為什么每次都查詢剛才查詢過的那張表??
2015-09-22
源自:Yii框架不得不說的故事—基礎篇(1) 5-3
正在回答
<?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表,將上述代碼改為
$sql = 'select * from users1 where id=1'; ? ? ? ? ? ? ? ? ?//這里做了改動
刷新頁面為什么提示
Invalid Configuration – yii\base\InvalidConfigException
The table does not exist: {{%users}}
我明明要查詢users1了呀,為什么還查詢之前的users?
貼出你寫的代碼
琴代語兮 提問者
舉報
通過本視頻教程,為學習YII的快速、安全、專業的特性打下基礎
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-09-23
<?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?
2015-09-23
貼出你寫的代碼