Showing posts with label yii. Show all posts
Showing posts with label yii. Show all posts

Tuesday, April 26, 2011

Yii CJSON

[cc lang="php"] $this->layout=false;
header('Content-type: application/json');
echo CJSON::encode(array('id'=>$project->id, 'content'=>$project->content, 'pass_way'=>$project->pass_way, 'total'=>$count, 'bs'=>$project->multiple
));
Yii::app()->end(); [/cc]

Saturday, August 21, 2010

How to get current controller name and action name in Yii

To get current controller name/id inside your controller, or view
[cc lang='php']$controllerId = Yii::app()->controller->id;
//or
$controllerId = $this->getId();[/cc]
To get current action name/id being executed, if you are inside [cci]beforeAction()[/cci] or [cci]afterAction()[/cci], use the received CAction argument
[cc lang='php']
//inside beforeAction or afterAction
public function beforeAction($action)
{
$actionId = $action->id;
...
[/cc]
or just elsewhere inside your controller

[cc lang='php']$actionId = $this->getAction()->getId();[/cc]

Monday, September 21, 2009

YII 数据库连接(MySQL)


'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=yiiblog;unix_socket=/opt/lampp/var/mysql/mysql.sock',
'username'=>'root',
'password'=>'password',
'charset'=>'utf8',