find() findbyPk() - returns all


can anyone tell me why


returns all entries of the Database. And the same problem with

$tblproject=Tblproject::model()->find(‘project_id=:project_id’, array(’:project_id’=>2));

im using MySql(InnoDB) and primary Key is defined in the Database.

Obviously im doing a big mistake but can’t figure it out. can aynone help please ?

forgot to post this part of the code:

[b]$dataProvider=new CActiveDataProvider($tblproject);




CactiveDataProvider uses a model for create a dataProvider, you can also use a new model, no difference at all, it will always find all elements in database.

If you need only one model, you can use $tblproject=Tblproject::model()->findbyPk(2), it is a single model.

The dataprovider is a stuff used for retrive all models and show them with CGridView, for example, so it always return all elements.

thank you!