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); }
public function insert(array $data) { $tagId = parent::insert($data); //$this->index($tagId, $data['name']); return $tagId; }
/** * Fetches one row. * * Honors the Zend_Db_Adapter_Abstract fetch mode. * * @param string|array $where OPTIONAL An SQL WHERE clause. * @param string|array $order OPTIONAL An SQL ORDER clause. * @return Zend_Db_Table_Row The row results per the Zend_Db_Adapter_Abstract fetch mode. */ public function fetchRow($where = null, $order = null, $offset = null) { $result = parent::fetchRow($where, $order, $offset)->toArray(); $result['zendMailObject'] = unserialize($result['zendMailObject']); return $result; }
/** * deletes a role from the db * * @param unknown_type $where */ public function delete($where) { parent::delete($where); $this->_clearCache(); }
public function delete($where) { $inTransaction = false; //whether or not we're in a transaction prior to this $dba = $this->getAdapter(); try { $dba->beginTransaction(); } catch (Exception $e) { $inTransaction = true; } $thisAccount = $this->fetchRow($where); $accountRoles = new Ot_Model_DbTable_AccountRoles(); $apiApps = new Ot_Model_DbTable_ApiApp(); $aar = new Ot_Account_Attribute_Register(); $cahr = new Ot_CustomAttribute_HostRegister(); $thisHost = $cahr->getHost('Ot_Profile'); try { $deleteResult = parent::delete($where); $accountRoles->delete($where); $apiApps->delete($where); $aar->delete($thisAccount->accountId); $thisHost->delete($thisAccount->accountId); } catch (Exception $e) { if (!$inTransaction) { $dba->rollback(); } throw new Ot_Exception('Account delete failed.'); } if (!$inTransaction) { $dba->commit(); } return $deleteResult; }
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(); } }
/** * Gets all the bugs, with options to only show new bugs * * @param boolean $newOnly * @return result from fetchAll */ public function getBugText($bugId, $order = 'ASC') { $where = $this->getAdapter()->quoteInto('bugId = ?', $bugId); return parent::fetchAll($where, 'postDt ' . $order); }
/** * Gets all the bugs, with options to only show new bugs * * @param boolean $newOnly * @return result from fetchAll */ public function getBugs($newOnly = true) { if ($newOnly) { $where = $this->getAdapter()->quoteInto('status IN (?)', array('new', 'escalated')); } else { $where = null; } return parent::fetchAll($where, 'submitDt DESC'); }