Builder::delete()
Run a delete operation against an existing model if the model has not been persisted on the DB the operation will fail.
Return
(int) The number of affected rows.
Source
File: src/Events/Custom_Tables/V1/Models/Builder.php
public function delete() {
$this->operation = 'DELETE';
global $wpdb;
$SQL = $this->get_sql();
// If the query is invalid, don't delete anything.
if ( $this->invalid ) {
return 0;
}
$this->queries[] = $SQL;
$result = $this->execute_queries ? $wpdb->query( $SQL ) : false;
// If an error happen or no row was updated by the query above.
if ( $result === false || (int) $result === 0 ) {
return 0;
}
$this->model->reset();
return absint( $result );
}
Changelog
| Version | Description |
|---|---|
| 6.1.3 | Integration with memoization. |
| 6.0.0 | Introduced. |