Cheetah
ChWsbSessionQuery.php
Go to the documentation of this file.
1 <?php
2 
8 require_once (CH_DIRECTORY_PATH_CLASSES . 'ChWsbDb.php');
9 
14 {
15  var $sTable;
16 
17  function __construct()
18  {
19  parent::__construct();
20 
21  $this->sTable = 'sys_sessions';
22  }
23  function getTableName()
24  {
25  return $this->sTable;
26  }
27  function exists($sId)
28  {
29  $aSession = $this->getRow("SELECT `id`, `user_id`, `data` FROM `" . $this->sTable . "` WHERE `id`= ? LIMIT 1", [$sId]);
30  return !empty($aSession) ? $aSession : false;
31  }
32  function save($sId, $aSet)
33  {
34  $sSetClause = "`id`='" . $sId . "'";
35  foreach($aSet as $sKey => $sValue)
36  $sSetClause .= ", `" . $sKey . "`='" . $sValue . "'";
37  $sSetClause .= ", `date`=UNIX_TIMESTAMP()";
38 
39  return (int)$this->query("REPLACE INTO `" . $this->sTable . "` SET " . $sSetClause) > 0;
40  }
41  function delete($sId)
42  {
43  return (int)$this->query("DELETE FROM `" . $this->sTable . "` WHERE `id`='" . $sId . "' LIMIT 1") > 0;
44  }
45  function deleteExpired()
46  {
47  $iRet = (int)$this->query("DELETE FROM `" . $this->sTable . "` WHERE `date`<(UNIX_TIMESTAMP()-" . CH_WSB_SESSION_LIFETIME . ")");
48  $this->query("OPTIMIZE TABLE `" . $this->sTable . "`");
49  return $iRet;
50  }
51 }
ChWsbSessionQuery\$sTable
$sTable
Definition: ChWsbSessionQuery.php:15
ChWsbSessionQuery\save
save($sId, $aSet)
Definition: ChWsbSessionQuery.php:32
php
ChWsbSessionQuery\__construct
__construct()
Definition: ChWsbSessionQuery.php:17
ChWsbDb\getRow
getRow($sQuery, $aBindings=[], $iFetchStyle=PDO::FETCH_ASSOC)
Definition: ChWsbDb.php:225
CH_WSB_SESSION_LIFETIME
const CH_WSB_SESSION_LIFETIME
Definition: ChWsbSession.php:10
ChWsbDb\query
query($sQuery, $aBindings=[])
Definition: ChWsbDb.php:386
$sId
$sId
Definition: actions.inc.php:8
ChWsbSessionQuery\exists
exists($sId)
Definition: ChWsbSessionQuery.php:27
ChWsbSessionQuery
Definition: ChWsbSessionQuery.php:14
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbDb
Definition: ChWsbDb.php:13
ChWsbSessionQuery\deleteExpired
deleteExpired()
Definition: ChWsbSessionQuery.php:45
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbSessionQuery\getTableName
getTableName()
Definition: ChWsbSessionQuery.php:23