Welcome Guest, Not a member yet? Register   Sign In
IgnitedRecord delete not working
#1

[eluser]Gaz[/eluser]
Hi all,

I'm using IgnitedRecord and it's a beautiful piece of work that has sped up my development no-end, but for some strange reason I cannot seem to delete records.

I'm probably doing something stupid as it's the first time I've used IR. The code looks like this

Code:
function delete($id)
{
    $this->rec = $this->{$this->name}->find($id);
    $this->rec->delete();
}

Creating and editing records works perfectly, so I'm puzzled as to why they won't delete. I don't get any error messages, and the code continues to run perfectly.

I can delete records from the db with my MySQL client (using the same MySQL login details), so it's not a permissions problem with MySQL.

I can also do a print_r on $this->rec and the object is there, with all the correct fields.

Any help would be much appreciated.

Cheers,
Gaz.
#2

[eluser]Jamie Rumbelow[/eluser]
Try going through the delete() function and die()ing at different points in the script - then you can find out where it's failing.
#3

[eluser]Gaz[/eluser]
OK, it dies in

ignitedquery.php / delete() at

Code:
if(empty($this->q_where) && empty($this->like))

although the parameters passed to the delete function seem valid. They are

Code:
[table] => categories
    [where] => Array
        (
            [id] => 6
        )

    [limit] =>
    [reset_data] => 1

I'm using IR version 1.0.0, by the way.
#4

[eluser]m4rw3r[/eluser]
I'm not at home for the moment (so I cannot upload to the SVN), but I will do a check with what I have and see if I can correct it.

Here are some small things that came to mind:
* $this->like should be $this->q_like (because otherwise empty($this->like) == true, always)
* Check the value of $this->q_where, it should be something like array('`id`' => '6')
#5

[eluser]Gaz[/eluser]
I'll look into it some more, but for now I've just used CodeIgniter's db->delete() function.
#6

[eluser]helmutbjorg[/eluser]
I have also hit this problem... with a simple ->find() and the a ->delete() on the object.
Did you have any luck. Perhaps it is problem with the 1.0 release?


Even as simple as this won't work... No errors thrown either.
Code:
$user = $this->user->find(1);
$user->delete();
#7

[eluser]m4rw3r[/eluser]
What version / revision are you using?
Because I think this was resolved earlier.

If it does not work, can you please send me (via PM) the idump() and the SQL generated by delete()?
#8

[eluser]helmutbjorg[/eluser]
I had version 1.0 from the Assembla zip page. Just used the SVN version and it works now.
Thanks for that.
teve




Theme © iAndrew 2016 - Forum software by © MyBB