秋天是收获的季节。柿子树上缀满了小红灯笼似的柿子,沉甸甸的,把枝头都压弯了。枫树的叶子火红火红的,像一堆正在燃烧的火焰。那梧桐树的枯叶在秋风中纷纷飘落下来,像翩翩起舞的金色蝴蝶。
本文实例讲述了Yii数据读取与跳转参数传递用法。分享给大家供大家参考,具体如下:
$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的结果是:
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的结果:
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() 不能同时使用 当$dataReader->read()读完之后$dataReader->readAll()读取的为空,反之一样。
通过render传递的参数可以这样调用:
<?php var_dump($toop); var_dump($var1); var_dump($var2); ?>
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
到此这篇关于Yii数据读取与跳转参数传递用法实例分析就介绍到这了。有人说,青春仿佛是朵素洁的昙花,来不及铺张来不及遐思,甚至来不及弥补欠缺和瑕庛,就那么匆匆地谢了。更多相关Yii数据读取与跳转参数传递用法实例分析内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!