Spot icon indicating copy to clipboard operation
Spot copied to clipboard

Collection update/delete

Open vlucas opened this issue 11 years ago • 0 comments

It would be nice to update and delete intuitively from an existing collection or query.

Examples

Delete all the comments for a post (through a relation) $post->comments->delete()

Delete all spam comments for a post (through a relation) $post->comments->delete(array('is_spam' => true)) $post->comments->where(array('is_spam' => true))->delete()

Update all the comments with a 'status' of 'published' (also through a relation) $post->comments->update(array('status' => 'published'))

Delete ALL posts from the table $mapper->all('Entity\Post')->delete()

Delete posts WHERE 'status' = 'deleted' $mapper->all('Entity\Post')->delete(array('status' => 'deleted'))

Archive all posts older than one year $mapper->all('Entity\Post')->where(array('date_published < ' => new \DateTime('-1 year'))->update(array('status' => 'archived'))

vlucas avatar Apr 10 '13 21:04 vlucas