Reputation: 1594
I fairly new to YII and still trying to understand it all. However from what I can tell when you do something like
yourModel->findAll(criteria)
Is like "Select * from"? or is it more like "Select yourModel->Attributes from"? In either case I was wondering in CDbCriteria is there a way to remove columns from the select. My case I have a user table that contains password I would like to prevent this from being added in the query.
Thanks,
Upvotes: 1
Views: 1886
Reputation: 17478
Ofcourse you can select specific columns, just use the select
property of CDbCriteria:
$criteria=new CDbCriteria();
$criteria->select='column1, column2';// or you can use array array('column1','column2')
$manymodels=$yourmodel->findAll($criteria);
So it is more like : "Select criteria->select from yourmodelclass' dbtable".
Note that findAll()
will return you an array of models.
Upvotes: 4