Improve API to return id instead of a boolean

This commit is contained in:
Frédéric Guillot
2014-11-22 18:22:10 -05:00
parent 15038cdb10
commit 77e10d2582
13 changed files with 270 additions and 310 deletions

View File

@@ -94,11 +94,18 @@ class Category extends Base
*
* @access public
* @param array $values Form values
* @return bool
* @return bool|integer
*/
public function create(array $values)
{
return $this->db->table(self::TABLE)->save($values);
return $this->db->transaction(function($db) use ($values) {
if (! $db->table(Category::TABLE)->save($values)) {
return false;
}
return (int) $db->getConnection()->getLastId();
});
}
/**