moved the site to the local openserver hosting. DB is connected, the path. It turns out such an error

Fatal error: Call to a member function asCMenuArray () on D

Lines of the code where he swears

<?php Yii::import('application.modules.store.models.StoreCategory'); $items = StoreCategory::model()->findByPk(1)->asCMenuArray(); if(isset($items['items'])) { $this->widget('application.extensions.mbmenu.MbMenu',array( 'htmlOptions'=>array('class'=>'catalog-menu', 'id'=>'nav'), 'items'=>$items['items']) ); } 

?>

  • This means findByPk(1) did not return anything and asCMenuArray nothing to apply. and not on the open server when there was a project - did not swear because the error output was probably turned off. And another version of php is different ... although the version doesn’t particularly affect this ... just had to switch on the error display before) and check that the data actually returned - Alex Shimansky
  • why then everything works on the combat server? - user217852
  • Because on the battle, error_reporting disabled, I guess. as I mentioned above - Alexey Shimansky
  • what exactly do I need to do now? - user217852
  • I tried to turn off error output, but this did not solve the problem - user217852

1 answer 1

You were told in the comments that findByPk(1) returns null , and not an object in which you can call the asCMenuArray() method. Therefore, you first need to check what findByPk(1) returns. As an option:

 <?php Yii::import('application.modules.store.models.StoreCategory'); $model = StoreCategory::model()->findByPk(1); $items = (!empty($model)?$model->asCMenuArray():array()); if(isset($items['items'])) { $this->widget('application.extensions.mbmenu.MbMenu',array( 'htmlOptions'=>array('class'=>'catalog-menu', 'id'=>'nav'), 'items'=>$items['items']) ); } 
  • it returns the main page of the page - user217852
  • Who returns where? - Bookin