insert($token); } /** * * @param array $token * @param integer $tokenid * @return integer */ public function updateToken($token, $tokenid) { if (!isset($token['mtime']) || empty($token['mtime'])) { $token['mtime'] = date(DATETIME_FORMAT); } $where = $this->getAdapter()->quoteInto($this->getAdapter()->quoteIdentifier('id') . ' = ?', $tokenid); return $this->update($token,$where); } /** * * @param string $tokenKey * @return array|null */ public function getTokenByRequestToken($tokenKey) { $sql = 'SELECT * FROM ' . $this->getTable() . ' WHERE ' . $this->getAdapter()->quoteInto($this->getAdapter()->quoteIdentifier('request_token') . ' = ?', $tokenKey); $row = $this->getAdapter()->query($sql)->fetchAll(); unset($sql); return (is_array($row) && count($row) > 0) ? $row[0] : null; } /** * * @param string $tokenKey * @return array|null */ public function getTokenByAccessToken($tokenKey) { $sql = 'SELECT * FROM ' . $this->getTable() . ' WHERE ' . $this->getAdapter()->quoteInto($this->getAdapter()->quoteIdentifier('access_token') . ' = ?', $tokenKey); $row = $this->getAdapter()->query($sql)->fetchAll(); unset($sql); return (is_array($row) && count($row) > 0) ? $row[0] : null; } /** * @return TokenModel */ public static function instance() { return parent::_instance(__CLASS__); } }