CodeIgniter Forums
Scaffolding > SQL error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Scaffolding > SQL error (/showthread.php?tid=1930)



Scaffolding > SQL error - El Forum - 07-05-2007

[eluser]Unknown[/eluser]
Hello,

I'm using CI 1.5.3, PHP 5.2.3 and MySQL 5.0.37. I have a table with the following structure:

Code:
CREATE TABLE `client` (
  `id` int(10) NOT NULL auto_increment,
  `first_name` varchar(50) NOT NULL,
  `last_name` varchar(50) NOT NULL,
  `address_1` varchar(75) NOT NULL,
  `address_2` varchar(75) NOT NULL,
  `city` varchar(50) NOT NULL,
  `state` char(2) NOT NULL,
  `zip` int(9) default NULL,
  `phone` int(10) default NULL,
  `cell` int(10) default NULL,
  `email` varchar(255) NOT NULL,
  `company` varchar(75) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

When I use scaffolding and try to insert a record (leaving an INT field "empty"), I get a Database error:

Code:
An Error Was Encountered

Error Number: 1366

Incorrect integer value: '' for column 'zip' at row 1

INSERT INTO client (first_name, last_name, address_1, address_2, city, state, zip, phone, cell, email, company) VALUES ('xxx', 'xxx', '', '', 'xxx', 'CA', '', '', '', '[email protected]', '')

I did some research and it appears that I can just edit the MySQL my.ini file and remove "STRICT_TRANS_TABLES" from sql-mode...but I wanted to know if there were any other options. I don't know that everyone normally can edit the MySQL my.ini file and it appears that the issue is cause by the scaffolding sending a '' instead of a null.

Any thoughts?


Scaffolding > SQL error - El Forum - 08-14-2007

[eluser]Unknown[/eluser]
I've got the same problem - seems really odd to me that CodeIgniter doesn't treat datatypes differently? wouldn't this be a huge issue 99% of tables out there that have non varchar columns - or am i just missing something?

Kurt