Skip to content

Delete with where? #234

@paulcanning

Description

@paulcanning

In my model, I'm writing a new method that calls several model methods inside a transaction.

The queries all deal with deleting data.

I am starting off with a call to the same model, deleting a row where the ID matches the input variable and a flag is set to 1

So, the first bit is easy, $this->delete($job_id) but I want to combine that with a WHERE statement, so I tried the following, based on the bit of documentation in the readme, $this->delete($job_id)->get_by('archived', 1); - this failed miserably with the following error

Fatal error: Call to a member function get_by() on a non-object

FYI, here is the code from the readme I'm referring too. I know it's about soft deletes, but I assume it should work with normal deletes?

=> $this->book_model->only_deleted()->get_by('user_id', 1);
-> SELECT * FROM books WHERE user_id = 1 AND deleted = 1

So, how do I do a delete with a where statement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions