課程
/后端開發(fā)
/PHP
/Yii框架不得不說的故事—基礎(chǔ)篇(1)
使用php yii 框架,第一次用php代碼查詢Mysql中的表后,修改php代碼,想要查詢另一張表,可為什么每次都查詢剛才查詢過的那張表??
2015-09-22
源自:Yii框架不得不說的故事—基礎(chǔ)篇(1) 5-3
正在回答
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Users;
class IndexController extends Controller{
public function actionIndex(){
//查詢數(shù)據(jù)
$sql = 'select * from users where id=1'; ? ? ? ? ? ? ? ? ?//一會兒將改這里
$results=Users::findBySql($sql)->all();
print_r($results);
}
查詢一次數(shù)據(jù)庫中users表后,刪掉users表,新建一個users1表,將上述代碼改為
$sql = 'select * from users1 where id=1'; ? ? ? ? ? ? ? ? ?//這里做了改動
刷新頁面為什么提示
Invalid Configuration – yii\base\InvalidConfigException
The table does not exist: {{%users}}
我明明要查詢users1了呀,為什么還查詢之前的users?
貼出你寫的代碼
琴代語兮 提問者
舉報
通過本視頻教程,為學(xué)習(xí)YII的快速、安全、專業(yè)的特性打下基礎(chǔ)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2015-09-23
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Users;
class IndexController extends Controller{
public function actionIndex(){
//查詢數(shù)據(jù)
$sql = 'select * from users where id=1'; ? ? ? ? ? ? ? ? ?//一會兒將改這里
$results=Users::findBySql($sql)->all();
print_r($results);
}
}
查詢一次數(shù)據(jù)庫中users表后,刪掉users表,新建一個users1表,將上述代碼改為
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Users;
class IndexController extends Controller{
public function actionIndex(){
//查詢數(shù)據(jù)
$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
貼出你寫的代碼