I need show data from database in the column2. How can do it?
I must write function in model or I can send from controler?
I need show data from database in the column2. How can do it?
I must write function in model or I can send from controler?
public $myattribute;
public function init()
{
$this->myattribute = Model::model()->findByPk(1);
}
var_dump($this->myattribute);
Thank You.
Can I write this function in model and use it in column or I should use controler?
public static function column(){
$model = self::model()->findByPk(1);
$data = array($model->myattribute1, $model->myattribute2);
return $data;
}
I don’t understand what is init().
Can you explain me when and where I can use function init()?
protected > components > Controller.php
class Controller extends CController
{
public $myattribute;
public function init()
{
$this->myattribute = Model::model()->findByPk(1);
}
}
Thank You!
I added in class Controller and now it works.
You should really start with some of the tutorials like the Blog. This will help you will Yii.