AR and findBySql


i spent whole morning on searching the answer to my questions but no results.

Basically i want to get only 2 columns from db. One primary key, and second that is name and surname joined together

the sql would be:

"SELECT loginname, concat(fname,' ',lname)as fullname FROM it_users"

so i made the method in Model:

public function findFullname() {

	return self::model()->findBySql('SELECT loginname, concat(fname," ",lname)as fullname FROM it_users');


After that i have only loginname attribute available. What should i do to use fullname too?

I know that i should add the property ‘fullname’ to the model, but how?

class Model extends...


   public $fullname;



It’s as simple as it could be.

Welcome to the forums!

i have it declared like u say already, but still:

private '_attributes' => 


      'loginname' => string 'xxxxxxx' (length=7)

ok sorry… my fault. I didn`t see the public variable on top of the dump…