1

I'm using Yii framework and it seems something goes wrong when I use its MVC,

I have model called Sav :

class Sav extends CActiveRecord{
private $id;
private $idmsg;
private $reclamation;

public function TableName(){
return 'sav';
}
public function primaryKey(){
    return 'id';
}
public function getId() {
    return $this->id;
}
public function getIdmsg() {
    return $this->idmsg;
}
public function getReclamation() {
    return $this->reclamation;
}

public function setId($id) {
    $this->id=$id;
}
public function setIdmsg($idmsg) {
    $this->idmsg=$idmsg;
}
public function setReclamation($reclamation) {
    $this->reclamation=$reclamation;
}
}

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field 'idmsg' doesn't have a default value. The SQL statement executed was: INSERT INTO sav (reclamation) VALUES (:yp0)

Here is my controller :

                $reclamation = new Sav;
                $reclamation->setId(88);
                $reclamation->setIdmsg(11);
                $reclamation->setReclamation("test");
                $reclamation->save();
Zacki
  • 23
  • 7
  • this is a SQL error, you can refer here http://stackoverflow.com/questions/18751291/mysql-error-1364-field-display-name-doesnt-have-default-value – Klaus Aug 11 '16 at 11:25
  • Thank you Klaus, but when I use public instead of private and $reclamation->idmsg=11; instead of $reclamation->setIdmsg(11); it works – Zacki Aug 11 '16 at 11:42

0 Answers0