Null is replaced with 0 when inserting int values in MySQL
Posted: Mon Jul 21, 2008 6:27 pm
Hi! I'm running CMS Made Simple version 1.2.2 and one of the latest versions of MySQL (Sorry, I do not know what version exactly is installed on the server).
I have an integer variable in the php code and when I try insert it into the database, I get 0 instead of null values.
Here is a code snippet
year is the integer variable.
My first guess was that the corresponding field in SOME_TABLE is not null, but it is nullable.
How can I insert null into an integer column in the table?
I have an integer variable in the php code and when I try insert it into the database, I get 0 instead of null values.
Here is a code snippet
Code: Select all
$sql = 'INSERT INTO '.cms_db_prefix().SOME_TABLE;
$sql .= ' (x, year) VALUES (?,?) ';
$dbresult = & $gCms->db->Execute($sql, array($this->_x, $this->_year));
My first guess was that the corresponding field in SOME_TABLE is not null, but it is nullable.
How can I insert null into an integer column in the table?