我有以下方法:如何使用模型對象的Yii控制器和視圖
public function actionIndex() {
$companyModel = Company::model()->findAll();
$supplierProductModel = SupplierProduct::model()->findAll();
$this->render('index', array(
'companyData' => $companyModel,
'supplierProductData' => $supplierProductModel,
));
}
在這裏,我已經通過模型對象渲染功能,並希望在視圖訪問這些對象(活動關係型),但是當我是訪問其在查看其表示錯誤:
Trying to get property of non-object
視圖文件(的index.php)
echo $companyData->name . "\n";
echo $this->companyModel->phone . "\n";
echo $this->companyModel->fax . "\n";
echo $this->companyModel->cell . "\n";
任何幫助,將不勝感激。