Yii Framework Forum: Solution For An Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Solution For An Error Column name must be either a string or an array Rate Topic: -----

#1 User is offline   TheEXE 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-September 13
  • Location:Kenya

Posted 05 September 2013 - 04:25 AM

Refer to the code in the actionUpdate of a relation scenario for tables:
public function actionUpdate($id)
{
$model=$this->loadModel($id);

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
{
$model->person->attributes=$_POST['Person'];
$model->person->save();

$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('update',array('model'=>$model,
));
}

The error proved to be hell of a thing but i realized it arose as a result of table persorn(profile for user) not having a PRIMARY KEY. The tables User and Person have a relation through a FOREIGN KEY. For one to UPDATE the user the tables must be both having a primary key.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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