Sankalp Singha Sankalp Singha - 5 months ago 15x
PHP Question

Yii params condition ( PHP Framework )

I am a complete newbie in the world of yii and doing my best to learn the framework as best as I can, while reading the book on Yii - 'Web Application Development Using Yii and PHP' by Jeffrey Winesett,

I came across :


If anyone has read the book, can someone explain why do we use :projectId why not directly projectId? What does the ':' stand for? Is it the specific syntax or is it something php specific.

This was the exact code :

public function actionIndex()

$dataProvider=new CActiveDataProvider('Issue', array(

Any answer would be highly appreciated.


The ":" id there to identify param within the condition string. It's a way to safely bind params to an sql statement.

In your case, when you specify this condition


In your db schema, Yii know that project_id is an integer, then when you bind the param with :


Yii will make sure you bind an integer and write the SQL statement for it and generate SQL statement like this : project_id=26

This is the same thing for string ex.:

            'params'=>array(':myname' => 'Ronald McDonald'),

then your sql statement for this condition will be name='Ronald McDonald'