1
votes

following are the fields in my company entity

/**
 * @var int
 *
 * @ORM\Column(name="plan", type="integer", nullable=true)
 */
private $plan;

/**
 * @var float
 *
 * @ORM\Column(name="wallet", type="float", nullable=true)
 */
private $wallet;

/**
 * @var string
 *
 * @ORM\Column(name="profpic", type="string", length=255, nullable=true)
 */
private $profpic;

/**
 * @var float
 *
 * @ORM\Column(name="tod1", type="float", nullable=true)
 */
private $tod1;

/**
 * @var float
 *
 * @ORM\Column(name="tod2", type="float", nullable=true)
 */
private $tod2;

/**
 * @var string
 *
 * @ORM\Column(name="tod3", type="string", length=255, nullable=true)
 */
private $tod3;

yet I face this error while registration:

An exception occurred while executing 'INSERT INTO company (email, pass, type, name, level, plan, wallet, profpic, tod1, tod2, tod3) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["[email protected]", "test", "comp", null, 1, null, null, null, null, null, null]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

what did I do wrong? Please help..

2
I guess that you've just added nullable parameter to your entity's attributes, but haven't updated the database schema. - Jakub Matczak
I have updated the database accordingly... yet the same problem is occurring - sameer manek

2 Answers

4
votes

From the error

An exception occurred while executing 'INSERT INTO company (email, pass, type, name, level, plan, wallet, profpic, tod1, tod2, tod3) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["[email protected]", "test", "comp", null, 1, null, null, null, null, null, null]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

The field name is required. In your entity above you forgot to post your name column. I am sure you made a mistake in the name column.
An example of a nullable name column is

/**
 * @ORM\Column(type="string" ,nullable=true)
 */
protected $name;

after that update your database schema with

$ php app/console doctrine:schema:update --force

and try again.

1
votes

Your error is Column 'name' cannot be null Is column name also set as nullable in entity (and NULL type in database) ?