/**
  * This is the insert method for the Author. This takes the current
  * `$this->_fields` values and adds them to the database using either the
  * `AuthorManager::edit` or `AuthorManager::add` functions. An
  * existing user is determined by if an ID is already set.
  *
  * @see toolkit.AuthorManager#add()
  * @see toolkit.AuthorManager#edit()
  * @return integer|boolean
  *  When a new Author is added or updated, an integer of the Author ID
  *  will be returned, otherwise false will be returned for a failed update.
  */
 public function commit()
 {
     if (!is_null($this->get('id'))) {
         $id = $this->get('id');
         $this->remove('id');
         if (AuthorManager::edit($id, $this->get())) {
             $this->set('id', $id);
             return $id;
         } else {
             return false;
         }
     } else {
         return AuthorManager::add($this->get());
     }
 }
Esempio n. 2
0
 public function commit()
 {
     $fields = $this->_fields;
     if (isset($fields['id'])) {
         $id = $fields['id'];
         unset($fields['id']);
         return AuthorManager::edit($id, $fields);
     } else {
         return AuthorManager::add($fields);
     }
 }