Select single record from DB, without defining Model.


how can I select one, single record from DB without defining new model?

I tried like this

$cmd = $db->createCommand('SELECT id FROM ..bla.. WHERE field = :a LIMIT 1');

$id = $cmd->query(array('a'=>$this->_fields[$field]);

$c = $id->next(); //i tried "current()" as well

however it returns null … the query itself is definitely ok, as changing from "SELECT" to "UPDATE" changes the record …

Now, how can I access the properties of selected record?


Try with

$c = $id->read();

You should use the queryRow method.