|
|
|
สอบถามการดึงข้อมูลใช้ CGridView Yii Framework ครับ |
|
|
|
|
|
|
|
คือผมลองเขียน Yii framework โดยดึงข้อมูลในฐานข้อมูลมาแสดงใน CGridView แต่มันขึ้นข้อความนี้
Code controller
Code (PHP)
<?php
class UserController extends Controller{
function actionCGridView (){
$sql = "SELECT * FROM tb_user";
//$model = new User();
$user = new CActiveDataProvider($sql);
$this->render("CGridView",array(
"user" => $user
)
);
}
}
?>
Code View
Code (PHP)
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $user,
'columns' => array( // กำหนด column ที่จะแสดง
'name' => 'id',
'header' => 'ID',
),
array(
'name' => 'user',
'header' => 'Username',
),
array(
'name' => 'pass',
'header' => 'Password',)
));
?>
Tag : PHP, Yii PHP Framework
|
|
|
|
|
|
Date :
2014-11-03 14:28:10 |
By :
bunditnu |
View :
1227 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
class UserController extends Controller{
function actionCGridView (){
$model = new User();
$user = new CActiveDataProvider('User');
$this->render("CGridView",array(
"user" => $user,
'model' => $model,
)
);
}
}
|
|
|
|
|
Date :
2014-11-05 09:14:36 |
By :
yokvoice |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|