I have a MySQL table structure:
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| reg | int(11) | NO | | NULL | |
| descr | text | YES | | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
+------------+----------+------+-----+---------+----------------+
And so I save the data in my database:
@saving = Table.new(:reg => 1234, :descr => params[:descr]).save
And my problem is I don’t know how this is possible, but this query does not save the number in the column "reg". I get this error
Mysql2::Error: Column 'reg' cannot be null: INSERT INTOname_of_table (updated_at ,DESCR ,p ,created_at) VALUES ('2011-06-06 20:40:43', 'description of man', NULL, '2011-06-06 20:40:43')
I worked a lot with PHP and the MySQL database, but I never got this error ... Where is the problem?
source
share