Yii Framework Forum: New to Yii, controller is throwing a fatal error via a model created by Giix - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

New to Yii, controller is throwing a fatal error via a model created by Giix Rate Topic: -----

#1 User is offline   snow_mac 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 23-April 12

Posted 23 April 2012 - 01:38 PM

So I've inherited a Yii application, I'm trying to get a piece this application to work that does a basic CRUD for management of Scientific factsheets. We're using Yii with Giix

This is the error:
"PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16 bytes) in /var/www/idtools.org/www/yii/framework/db/ar/CActiveRecord.php on line 58"

The update action is giving us the problems. The update looks like this in the controller:
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,
));
}

The view looks like:
<?php

$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));
?>

The model (as generated by Giix) looks like:
Yii::import('application.models._base.BaseFactsheet');

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

the model extends the base:
abstract class BaseFactsheet extends 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,
));
}
}


Any idea how to fix my issue? I've given PHP all of my systems memory (memory_init(-1)) and just gotten heap dump errors. I need help, please tell me where to look as I am totally new to Yii.
0

#2 User is offline   windsurfer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 11-April 12

Posted 27 April 2012 - 03:14 PM

Check that requirements are met.

Suggestion: setup a local web development on your computer with xampp or wamp. Download your Yii app to your computer. Then enable error reporting and logging.

Yii forum is not allowing me to provide links. Search for Larry Ullman on Yii. Look for part 1 of 8 for how to check the requirements. Look for part 3 of 8 for how to configure error reporting and debugging.

I'm a newbie to Yii and PHP but will help with what I have learned thus far.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users