示例#1
0
 public function recordSession(Mage_Api_Model_User $user)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getTable('api/session'), 'user_id')->where('user_id = ?', $user->getId())->where('sessid = ?', $user->getSessid());
     $logdate = now();
     if ($this->_getReadAdapter()->fetchRow($select)) {
         $this->_getWriteAdapter()->update($this->getTable('api/session'), array('logdate' => $logdate), $this->_getReadAdapter()->quoteInto('user_id = ?', $user->getId()) . ' AND ' . $this->_getReadAdapter()->quoteInto('sessid = ?', $user->getSessid()));
     } else {
         $this->_getWriteAdapter()->insert($this->getTable('api/session'), array('user_id' => $user->getId(), 'logdate' => $logdate, 'sessid' => $user->getSessid()));
     }
     $user->setLogdate($logdate);
     return $this;
 }
示例#2
0
 /**
  * Authenticate user by $username and $password
  *
  * @param string $username
  * @param string $password
  * @return boolean|Object
  */
 public function recordLogin(Mage_Api_Model_User $user)
 {
     $data = array('logdate' => now(), 'lognum' => $user->getLognum() + 1, 'sessid' => $user->getSessid());
     $condition = $this->_getWriteAdapter()->quoteInto('user_id=?', $user->getUserId());
     $this->_getWriteAdapter()->update($this->getTable('api/user'), $data, $condition);
     return $this;
 }