Yii數(shù)據(jù)讀取與跳轉(zhuǎn)參數(shù)傳遞用法實(shí)例分析
本文實(shí)例講述了Yii數(shù)據(jù)讀取與跳轉(zhuǎn)參數(shù)傳遞用法。分享給大家供大家參考,具體如下:
$toop=array('id'=>'aaaa','name'=>'bbbb','nickname'=>'ccccc','phone'=>'ddddd','status'=>'eeeeee','mytest'=>$te);
$test='hello world!';
$te="\$this->test='qweqw'";
$conn=Yii::app()->db;
$sql="select * from tbl_user";
$command=$conn->createCommand($sql);
$dataReader=$command->query();
//$rows=$dataReader->readAll();
while(($row=$dataReader->read())!==false) {
var_dump($row);
}
$this->render('index',array('toop'=>$toop,'var1'=>$test,'var2'=>$te));
$row的結(jié)果是:
array (size=4) 'id' => string '1' (length=1) 'username' => string 'test1' (length=5) 'password' => string 'pass1' (length=5) 'email' => string 'test1@example.com' (length=17) array (size=4) 'id' => string '2' (length=1) 'username' => string 'test2' (length=5) 'password' => string 'pass2' (length=5) 'email' => string 'test2@example.com' (length=17) array (size=4) 'id' => string '3' (length=1) 'username' => string 'test3' (length=5) 'password' => string 'pass3' (length=5) 'email' => string 'test3@example.com' (length=17)
$rows的結(jié)果:
array (size=21) 0 => array (size=4) 'id' => string '1' (length=1) 'username' => string 'test1' (length=5) 'password' => string 'pass1' (length=5) 'email' => string 'test1@example.com' (length=17) 1 => array (size=4) 'id' => string '2' (length=1) 'username' => string 'test2' (length=5) 'password' => string 'pass2' (length=5) 'email' => string 'test2@example.com' (length=17) 2 => array (size=4) 'id' => string '3' (length=1) 'username' => string 'test3' (length=5) 'password' => string 'pass3' (length=5) 'email' => string 'test3@example.com' (length=17) 3 => array (size=4) 'id' => string '4' (length=1) 'username' => string 'test4' (length=5) 'password' => string 'pass4' (length=5) 'email' => string 'test4@example.com' (length=17)
$dataReader->read() 與 $dataReader->readAll() 不能同時(shí)使用 當(dāng)$dataReader->read()讀完之后$dataReader->readAll()讀取的為空,反之一樣。
通過render傳遞的參數(shù)可以這樣調(diào)用:
<?php var_dump($toop); var_dump($var1); var_dump($var2); ?>
更多關(guān)于Yii相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結(jié)》、《php優(yōu)秀開發(fā)框架總結(jié)》、《smarty模板入門基礎(chǔ)教程》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設(shè)計(jì)有所幫助。
- Yii2增刪改查之查詢 where參數(shù)詳細(xì)介紹
- Yii框架參數(shù)化查詢中IN查詢只能查詢一個(gè)的解決方法
- yii2 在控制器中驗(yàn)證請求參數(shù)的使用方法
- Yii2框架配置文件(Application屬性)與調(diào)試技巧實(shí)例分析
- Yii配置文件用法詳解
- yii框架配置默認(rèn)controller和action示例
- PHP的Yii框架中使用數(shù)據(jù)庫的配置和SQL操作實(shí)例教程
- Yii學(xué)習(xí)總結(jié)之安裝配置
- YII2 實(shí)現(xiàn)多語言配置的方法分享
- Yii框架參數(shù)配置文件params用法實(shí)例分析
相關(guān)文章
thinkPHP+LayUI 流加載實(shí)現(xiàn)功能
這篇文章主要介紹了thinkPHP+LayUI 流加載實(shí)現(xiàn)功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09
一個(gè)簡單安全的PHP驗(yàn)證碼類、PHP驗(yàn)證碼
這篇文章主要介紹了一個(gè)簡單安全的PHP驗(yàn)證碼類 PHP驗(yàn)證碼的相關(guān)資料,需要的朋友可以參考下2016-09-09
在PHP站點(diǎn)的頁面上添加Facebook評論插件的實(shí)例教程
這篇文章主要介紹了在PHP站點(diǎn)的頁面上添加Facebook評論插件的實(shí)例教程,這樣用戶便可以以Facebook的用戶身份在Facebook樣式的評論表單上發(fā)表評論,需要的朋友可以參考下2016-01-01

