php - Passing NULL values into mysql Stored procedure -
i trying pass few null values stroed procedure php retains varaibles empty strings '' , not null.
my db insert function looks this. (i using framework , adodb if looks weird thats why).
function insert_emp($f_name, $last_name, $dob) { if(!isset($dob)){ $dob = null; } $this->db->setconnection("call insert_emp('$f_name', '$l_name', '$dob')"); }
i have ensured $dob being passed empty string ''. reason when calls stored proc not changed null. dob datetime field , mysql complains can not enter empty string datetime. if hard code insert such this
$this->db->setconnection("call insert_emp('test1', 'test2', 'null')");
it work. help.
null cannot represented string. should use string literal null.
function insert_emp($f_name, $last_name, $dob = 'null') { $this->db->setconnection("call insert_emp('$f_name', '$l_name', '$dob')"); }
i have set default value, , should wanted in first place.
Comments
Post a Comment