Skip to content

Instantly share code, notes, and snippets.

@kemo
Created March 31, 2012 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemo/2261086 to your computer and use it in GitHub Desktop.
Save kemo/2261086 to your computer and use it in GitHub Desktop.
Initial ORM::delete_all() 'idea'
<?php
public function delete_all()
{
$objects = $this->find_all()
->as_array($this->_primary_key);
if (method_exists($this, '_delete_row'))
{
foreach ($objects as $object)
{
$result = $this->_delete_row($object);
// If ORM::delete_row() returns FALSE, row should not be deleted
if ($result === FALSE)
{
unset($pks[$object->pk()]);
}
}
}
return DB::delete($this->_table_name)
->where($this->_primary_key, 'IN', array_keys($objects))
->execute($this->_db);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment