10 defined(
'JPATH_PLATFORM') or die;
32 JLog::add(
'JTableSession is deprecated. Use SQL queries directly to interact with the session table.',
JLog::WARNING,
'deprecated');
33 parent::__construct(
'#__session',
'session_id', $db);
50 public function insert($sessionId, $clientId)
52 $this->session_id = $sessionId;
53 $this->client_id = $clientId;
56 $ret = $this->_db->insertObject($this->_tbl, $this,
'session_id');
60 $this->setError(
JText::sprintf(
'JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
80 public function update($updateNulls =
false)
83 $ret = $this->_db->updateObject($this->_tbl, $this,
'session_id', $updateNulls);
87 $this->setError(
JText::sprintf(
'JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
108 public function destroy($userId, $clientIds = array())
110 $clientIds = implode(
',', $clientIds);
112 $query = $this->_db->getQuery(
true)
113 ->delete($this->_db->quoteName($this->_tbl))
114 ->where($this->_db->quoteName(
'userid') .
' = ' . $this->_db->quote($userId))
115 ->where($this->_db->quoteName(
'client_id') .
' IN (' . $clientIds .
')');
116 $this->_db->setQuery($query);
118 if (!$this->_db->execute())
120 $this->setError($this->_db->stderr());
138 public function purge($maxLifetime = 1440)
140 $past = time() - $maxLifetime;
141 $query = $this->_db->getQuery(
true)
142 ->delete($this->_db->quoteName($this->_tbl))
143 ->where($this->_db->quoteName(
'time') .
' < ' . (int) $past);
144 $this->_db->setQuery($query);
146 return $this->_db->execute();
159 public function exists($userid)
161 $query = $this->_db->getQuery(
true)
162 ->select(
'COUNT(userid)')
163 ->from($this->_db->quoteName($this->_tbl))
164 ->where($this->_db->quoteName(
'userid') .
' = ' . $this->_db->quote($userid));
165 $this->_db->setQuery($query);
167 if (!$result = $this->_db->loadResult())
169 $this->setError($this->_db->stderr());
174 return (
boolean) $result;
189 public function delete($oid = null)
191 $k = $this->_tbl_key;
198 $query = $this->_db->getQuery(
true)
199 ->delete($this->_db->quoteName($this->_tbl))
200 ->where($this->_db->quoteName($this->_tbl_key) .
' = ' . $this->_db->quote($this->$k));
201 $this->_db->setQuery($query);
203 $this->_db->execute();