使用 Giix 的 Yii 控制器中的致命错误


Fatal error in a Yii controller using Giix

所以我继承了一个 Yii 应用程序,我正在尝试让这个应用程序工作,为科学情况说明书的管理做一个基本的 CRUD。我们将 Yii 与 Giix 一起使用

这是错误:"PHP 致命错误:允许 134217728 字节的内存大小耗尽(尝试分配 16 字节)在/var/www/idtools.org/www/yii/framework/db/ar/CActiveRecord.php第 58 行"

更新操作给我们带来了问题。控制器中的更新如下所示:

public function actionUpdate($id) {
    $model = $this->loadModel($id, 'Factsheet');
    if (isset($_POST['Factsheet'])) {
        $model->setAttributes($_POST['Factsheet']);
        if ($model->save()) {
            $this->redirect(array('view', 'id' => $model->factsheetid));
        }
    }
    $this->render('update', array(
            'model' => $model,
            ));
}

视图如下所示:

$this->breadcrumbs = array(
    $model->label(2) => array('index'),
    GxHtml::valueEx($model) => array('view', 'id' => GxActiveRecord::extractPkValue($model, true)),
    Yii::t('app', 'Update'),
);
$this->menu = array(
    array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url'=>array('index')),
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url'=>array('create')),
    array('label' => Yii::t('app', 'View') . ' ' . $model->label(), 'url'=>array('view', 'id' => GxActiveRecord::extractPkValue($model, true))),
    array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url'=>array('admin')),
);
?>
<h1><?php echo Yii::t('app', 'Update') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model)); ?></h1>
<?php
$this->renderPartial('_form', array(
        'model' => $model));
?>

该模型(由 Giix 生成)如下所示: Yii::import('application.models._base.基本情况说明书");

class Factsheet extends BaseFactsheet
{
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }
}   

该模型扩展了基础: 抽象类 BaseFactsheet 扩展了 GxActiveRecord {

    public static function model($className=__CLASS__) {
        return parent::model($className);
    }
    public function tableName() {
        return 'factsheet';
    }
    public static function label($n = 1) {
        return Yii::t('app', 'Factsheet|Factsheets', $n);
    }
    public static function representingColumn() {
        return 'name';
    }
    public function rules() {
        return array(
            array('name, toolid', 'required'),
            array('weight', 'numerical', 'integerOnly'=>true),
            array('name, toolid', 'length', 'max'=>255),
            array('inputdate', 'safe'),
            array('weight, inputdate', 'default', 'setOnEmpty' => true, 'value' => null),
            array('factsheetid, name, toolid, weight, inputdate', 'safe', 'on'=>'search'),
        );
    }
    public function relations() {
        return array(
            'tool' => array(self::BELONGS_TO, 'Tool', 'toolid'),
            'factsheetcontents' => array(self::HAS_MANY, 'Factsheetcontent', 'factsheetid'),
            'factsheetimages' => array(self::HAS_MANY, 'Factsheetimages', 'factsheetid'),
        );
    }
    public function pivotModels() {
        return array(
        );
    }
    public function attributeLabels() {
        return array(
            'factsheetid' => Yii::t('app', 'Factsheetid'),
            'name' => Yii::t('app', 'Name'),
            'toolid' => null,
            'weight' => Yii::t('app', 'Weight'),
            'inputdate' => Yii::t('app', 'Inputdate'),
            'tool' => null,
            'factsheetcontents' => null,
            'factsheetimages' => null,
        );
    }
    public function search() {
        $criteria = new CDbCriteria;
        $criteria->compare('factsheetid', $this->factsheetid);
        $criteria->compare('name', $this->name, true);
        $criteria->compare('toolid', $this->toolid);
        $criteria->compare('weight', $this->weight);
        $criteria->compare('inputdate', $this->inputdate, true);
        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }
}

知道如何解决我的问题吗?我已经为 PHP 提供了我所有的系统内存 (memory_init(-1)),并且只是得到了堆转储错误。我需要帮助,请告诉我在哪里看,因为我对 Yii 完全陌生。

通常会在_form部分文件中收到该错误。 当GxHtml生成下拉菜单时,我经常遇到它。

GiiX 在正确将所有模型从数据库中提取并为下拉菜单获取适当的键/名称方面效率不高。 因此,通常最好指定要手动检索的字段。

如果您发布_form代码(或至少相关部分),我们可以指出该行。