Ejemplo n.º 1
0
 /**
  * Saves Entity User in DB
  *
  * @param  \Entity\User $user
  * @return \PDOStatement
  * @since  1.1
  */
 public function saveUser(\Entity\User $user)
 {
     $userMapper = new UserMapper();
     $data = $userMapper->extract($user);
     $userId = call_user_func(array($user, 'get' . ucfirst($userMapper->getIdColumn())));
     if (array_key_exists($userId, $this->identityMap['users'])) {
         return $this->em->update('users', $data, $userId, $userMapper->getIdColumn());
     }
     return $this->em->insert('users', $data);
 }
Ejemplo n.º 2
0
 /**
  * @param null $criteria
  * @return mixed
  */
 public function update($criteria = null)
 {
     if (!isset($criteria)) {
         $criteria = array("id" => $this->getPrimaryKey());
     }
     return $this->entityManager->update($this->tableName, $this->object, $criteria);
 }