Adding a class as property in an CActiveRecord model

HI all

i have a CActiveRecord called User

this user will have a mobile device of class Device

where


User - > device = new device()

how can i do something to be like :




echo $user->device->getBrandName();



the Device class is not linked in anyway to database

Thank you .




class User extends CActiveRecord

{

  public function getDevice()

  {

    return new Device();

  }

}


class Device

{

  public function getBrandName()

  {

    return $this->brandName;

  }

}



i don’t want to create a new device , i want that user to have a device class and use it’s methods (user->device->call() for example

Do you mean


 

class User {

	public $device = 'Device';

}







class Device {


	public static function call() {

		echo 'hello';

	}

}




$user = new User;

$deviceClass = $user->device;

$deviceClass::call();



no i mean something like :


class user{

  function __construct(){

    $this->device = new Device(5);

  }

}

you can overwrite the afterFind()-method of User, where you create the device for the found user record