using active record (delete) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: using active record (delete) (/showthread.php?tid=25841) |
using active record (delete) - El Forum - 12-28-2009 [eluser]kikz4life[/eluser] hi, still newbie to CI, i have this code in standard php. Now i want to use the CI active record (crud). Can anyone help me with this.? I tried modifying it and using the CI active record in delete. Code: $this->db->delete('sec_role', array('role_id' => $crudColumnValues['id'])); this is the standard code Code: case $crudConfig['create']: any suggestion or pointer will be a great help for me. thanks thanks using active record (delete) - El Forum - 12-28-2009 [eluser]cahva[/eluser] Well this should work: Code: $this->db->delete('sec_role', array('role_id' => $crudColumnValues['id'])); Did you get any error why it didnt work? Does the $crudColumnValues['id'] contain the id you want to delete? You can use $this->db->last_query() to see what is the last query. using active record (delete) - El Forum - 12-28-2009 [eluser]kikz4life[/eluser] yes, $crudColumnValues[‘id’] contains the value i want to delete cause if i use my original code(not using CI) it can delete the row. but using this $this->db->delete('sec_role', array('role_id' => $crudColumnValues['id'])); it aint. ( no error response in my firebug. also i used the $this->db->last_query() but i didnt see the result of my last queried. How come? also i tried to echo the result of $crudColumnValues['id'] by doing this echo $crudColumnValues['id'] and the result is 34 and thats the id i want to create., i saw this in my firebug. i'll try every solution you'll come up. really want to work this in CI framework thanks for the reply cahva using active record (delete) - El Forum - 12-28-2009 [eluser]cahva[/eluser] If the last_query didnt work, put this inside your controller's method: Code: $this->output->enable_profiler(TRUE); That will give you detailed information about queries + much more(what libraries are loaded etc.) using active record (delete) - El Forum - 12-28-2009 [eluser]kikz4life[/eluser] hi cahva, Code: ive tried what you've suggested to snip this code: $this->output->enable_profiler(TRUE); what do you think the problem? i'm frequently checking my thread so i can try every possible way to solve this. thanks using active record (delete) - El Forum - 12-28-2009 [eluser]cahva[/eluser] Well that kind of explains why it doesnt work. Its trying to delete role_id with id '"34"' (with quotes). Have you done something to the variable when putting it to $crudColumnValues['id'] variable? Does your code work if you use: Code: $this->db->delete('sec_role', array('role_id' => $this->input->post('id'))); using active record (delete) - El Forum - 12-28-2009 [eluser]kikz4life[/eluser] it worked! haha., thanks a many cahva.. also could you help me about using the CI active record update Code: case $crudConfig['update']: for the update i've read the manual, but the above code seems a little more complex for me. Also i would like to ask the differences of => to =. From my thoughts "=>" means of the array and for "=" will return strings. Am i right? Sorry for this . |