Пример #1
0
 public function persist(UserMeta $userMeta, $mode = 'insert')
 {
     $data = new ArrayObject(array('user_id' => $userMeta->getUser()->getUserId(), 'meta_key' => $userMeta->getMetaKey(), 'meta' => $userMeta->getMetaRaw()));
     $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('data' => $data, 'userMeta' => $userMeta));
     if ('update' === $mode) {
         $this->getTableGateway()->update((array) $data, array('user_id' => $userMeta->getUser()->getUserId(), 'meta_key' => $userMeta->getMetaKey()));
     } elseif ('insert' === $mode) {
         $this->getTableGateway()->insert((array) $data);
     }
     return $userMeta;
 }
Пример #2
0
 public function persist(UserMetaModel $userMeta, $mode = 'insert')
 {
     $data = new ArrayObject(array('user_id' => $userMeta->getUser()->getUserId(), 'meta_key' => $userMeta->getMetaKey(), 'meta' => $userMeta->getMetaRaw()));
     $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('data' => $data, 'userMeta' => $userMeta));
     $db = $this->getWriteAdapter();
     if ('update' === $mode) {
         $db->update($this->getTableName(), (array) $data, $db->quoteInto('user_id = ? AND ', $userMeta->getUser()->getUserId()) . $db->quoteInto('meta_key = ?', $userMeta->getMetaKey()));
     } elseif ('insert' === $mode) {
         $db->insert($this->getTableName(), (array) $data);
     }
     return $userMeta;
 }