HosipLan

Untitled

Nov 22nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. public function update($data)
  2. {
  3.     if ($data instanceof \Nette\Utils\ArrayHash) {
  4.         $data = iterator_to_array($data);
  5.     }
  6.  
  7.     if (!is_array($data)) {
  8.         throw new \InvalidArgumentException;
  9.     }
  10.  
  11.         if (isset($data['id'])) {
  12.             return $this->getTable()->where('id = ?', $data['id'])->update($data) ? $data['id'] : NULL;
  13.  
  14.         } elseif (count($data) > 0) {
  15.             return $this->insert($data);
  16.         }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment