Skip to content

Deleting records

Deleting records is done by using the delete() and from() methods.

Basic usage

php
$query_builder = new QueryBuilder();

$query_builder->delete()
    ->from('users')
    ->where('status')->is('inactive');

The delete() method returns a Delete object, which has a from() method to specify the table to delete from. The where() method is used to specify the conditions for the delete operation.

Joins

You can also use the join() method to specify a join condition.

php
$query_builder->delete()
    ->from('users')
    ->where('status')->is('inactive')
    ->join('another_table', 'table_name.id', '=', 'another_table.table_id');

The Delete class provides a fluent interface for building DELETE queries, allowing you to easily construct complex queries with conditions and joins if necessary.

Released under the MIT License.