PHP
·
发表于 5年以前
·
阅读量:8298
±¾ÎÄʵÀý½²ÊoÁËYiiÊý¾Ý¶ÁÈ¡ÓeÌøת²ÎÊý´«µÝÓè¡£ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º
$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µÄ½a¹uÊÇ£º
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µÄ½a¹u£º
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() Óe $dataReader->readAll() ²»ÄÜͬʱʹÓà µ±$dataReader->read()¶ÁÍeÖ®ºo$dataReader->readAll()¶ÁÈ¡µÄΪ¿Õ£¬*´Ö®Ò»Ñu¡£
ͨ¹ýrender´«µÝµÄ²ÎÊý¿ÉÒÔÕaÑuµ÷Óãº
<?php
var_dump($toop);
var_dump($var1);
var_dump($var2);
?>
¸u¶a¹ØÓÚYiiÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶Yii¿o¼ÜÈeÃż°³£Óü¼ÇÉ×ܽa¡¡¢¡¶[phpÓÅÐa¿ª¢¿o¼Ü×ܽa](http://www.jb51.net/Special/155.htm)¡¡¢¡¶smartyÄ£°aÈeÃÅ»u´¡½Ì³Ì¡¡¢¡¶phpÈÕÆÚÓeʱ¼aÓÃ*¨×ܽa¡¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶php×Öu´®(string)Óè×ܽa¡¡¢¡¶php+mysqlÊý¾Ý¿a²Ù×÷ÈeÃŽ̡̳¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡*
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼Ò»uÓÚYii¿o¼ÜµÄPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£