Last updated: Tue, Mar 25, 2025 2:25 pm
Return to Knowledgebase
# | Parameter | Data Type | Required | Description |
---|---|---|---|---|
1 | $table | string | Yes | Name of database table to delete records from. |
2 | $where | array | Yes | Associative array representing the condition(s) to identify the records to be deleted. |
// Condition Array:
// [ Column name, Type of comparison, Values]
// Deleting records from the 'users' table where the 'id' is 5
$result = $db->delete('users', ["id", "=", 5]);
//as of UserSpice 5.8.3 you can simply pass an int for the second parameter if you want to assume "id", "=",
$result = $db->delete('users', 5);
// more examples or condition arrays
["username", "LIKE", "a{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d}"]
["custom5", "IS NULL"]
["logins", "BETWEEN", 10, 30]
["permissions", "IN", [1,2]]