Skip to content

Commit 5914b95

Browse files
committed
#3 - Provide deleteBy($criteria)
1 parent 4900b23 commit 5914b95

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/TgDatabase/DAO.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ public function delete($object) {
192192
return FALSE;
193193
}
194194

195+
196+
/**
197+
* Delete the objects using the given criteria.
198+
* @param array $criteria - the criterions to match for delete for (AND) - see README.md (optional, default will clear table)
199+
* @return mixed - FALSE when delete failed, TRUE when successful
200+
*/
201+
public function deleteBy($criteria = array()) {
202+
$whereClause = $this->createWhereClause($criteria);
203+
$query = 'DELETE FROM '.$this->database->quoteName($this->tableName).' '.$whereClause;
204+
return $this->database->query($query);
205+
}
206+
195207
/**
196208
* Get the full SQL query to delete the given uid.
197209
* <p>Override this to implement soft delete functionality.</p>

0 commit comments

Comments
 (0)