Active Record Inserting 0 - 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: Active Record Inserting 0 (/showthread.php?tid=11156) |
Active Record Inserting 0 - El Forum - 08-28-2008 [eluser]Firstrow[/eluser] Hello all, I have a problem with Active Record inserting. Code in controller: Code: function insert() Code in Model: Code: function insert($data) sql: Code: `title` varchar(255) NOT NULL, Here is my problem: if title or keywords in $data array are empty its inserting 0 but i need to insert real empty string not 0. Can somebody help me? Active Record Inserting 0 - El Forum - 08-28-2008 [eluser]ontguy[/eluser] could you included your view? I encountered this in the past, I don't recall exactly what I did to avoid it. Active Record Inserting 0 - El Forum - 08-28-2008 [eluser]Firstrow[/eluser] My view file is simple (using parser): title: {title} keywors: {keywords} But the problem is not in view file. Problem is in inserting/updateing data thru Active Record Becouse it's writing 0 in db instead of empty string. I've wrote this function to avoid my problem: Code: function _delete_zero($arr) and using it in each model function: Code: $data = $this->_delete_zero($data); and its worked for me. And i dont know how it will work in other Db insted of MySql. I want to know why AR inserting 0. Active Record Inserting 0 - El Forum - 08-28-2008 [eluser]ontguy[/eluser] Try this in your view, I think that's what I did to avoid this issue: Code: <input type="text" name="title" value="<?=$this->validation->title; ?>" /><br /> Another alternative to what you have is: Code: $data = array( Active Record Inserting 0 - El Forum - 08-28-2008 [eluser]Firstrow[/eluser] Thanks! thats what i need. Code: $data = array( |