Some refactoring for PHP 5.3

This commit is contained in:
Frédéric Guillot
2014-11-22 18:49:34 -05:00
parent 77e10d2582
commit c49d46718a
9 changed files with 39 additions and 67 deletions

View File

@@ -90,6 +90,26 @@ abstract class Base
return Tool::loadModel($this->container, $name);
}
/**
* Save a record in the database
*
* @access public
* @param string $table Table name
* @param array $values Form values
* @return boolean|integer
*/
public function persist($table, array $values)
{
return $this->db->transaction(function($db) use ($table, $values) {
if (! $db->table($table)->save($values)) {
return false;
}
return (int) $db->getConnection()->getLastId();
});
}
/**
* Remove keys from an array
*