/** * Updates the table * * @param array $data The column=>value paired array of data * @param string $where The sql where clause to use * @return Result from Zend_Db_Table::update() */ public function update(array $data, $where) { if (isset($data['zendMailObject'])) { $data['zendMailObject'] = serialize($data['zendMailObject']); } return parent::update($data, $where); }
public function generateCodeForUser($userId) { $data = array('userId' => $userId, 'code' => md5(microtime())); $thisCode = $this->find($userId); if (is_null($thisCode)) { parent::insert($data); } else { parent::update($data, null); } return $data['code']; }
public function regenerateApiKey($appId) { $data = array('appId' => $appId, 'apiKey' => $this->_generateApiKey()); return parent::update($data); }
/** * Updates an existing role in the database * * @param array $data * @param string $where * @return unknown */ public function update(array $data, $where) { parent::update($data, $where); $this->_clearCache(); }
/** * updates the row * if you supply an array of role ids, it will update them correctly in the account_roles table */ public function update(array $data, $where) { $rolesToAdd = array(); if (isset($data['role']) && count($data['role']) > 0) { $rolesToAdd = (array) $data['role']; unset($data['role']); } $updateCount = parent::update($data, $where); if (count($rolesToAdd) < 1) { return $updateCount; } $accountRoles = new Ot_Model_DbTable_AccountRoles(); $accountRolesDba = $accountRoles->getAdapter(); $accountId = $data['accountId']; if (isset($rolesToAdd) && count($rolesToAdd) > 0 && $accountId) { try { $where = $accountRolesDba->quoteInto('accountId = ?', $accountId); $accountRoles->delete($where); foreach ($rolesToAdd as $roleId) { $d = array('accountId' => $accountId, 'roleId' => $roleId); $accountRoles->insert($d); } } catch (Exception $e) { throw $e; } } return $updateCount; }
public function update(array $data, $where) { $keys = array(); $dba = $this->getAdapter(); $inTransaction = false; try { $dba->beginTransaction(); } catch (Exception $e) { $inTransaction = true; } $evaluationKey = new Evaluation_Key(); if ($data['evaluationType'] == 'google') { $keys['eventId'] = $data['eventId']; $keys['formKey'] = $data['formKey']; $keys['answerKey'] = $data['answerKey']; try { $evaluationKey->update($keys, null); } catch (Exception $e) { $dba->rollBack(); throw $e; } } elseif ($data['evaluationType'] == 'default') { $where = $evaluationKey->getAdapter()->quoteInto('eventId = ?', $data['eventId']); try { $evaluationKey->delete($where); } catch (Exception $e) { $dba->rollBack(); throw $e; } } unset($data['formKey'], $data['answerKey']); try { parent::update($data, $where); } catch (Exception $e) { $dba->rollBack(); throw $e; } if (!$inTransaction) { $dba->commit(); } }
public function update(array $data, $where) { $dba = $this->getAdapter(); $dba->beginTransaction(); if (isset($data['text'])) { $bt = new Ot_Model_DbTable_BugText(); $text = $data['text']; unset($data['text']); try { $bt->insert($text); } catch (Exception $e) { $dba->rollback(); throw $e; } } try { parent::update($data, $where); } catch (Exception $e) { $dba->rollback(); throw $e; } $dba->commit(); }