コード例 #1
0
ファイル: Handler.php プロジェクト: IMPHP/libimphp
 public function gc()
 {
     if (Database::isConnected()) {
         $time = time() - $this->mMaxLifeTime;
         Database::delete("sessions")->cond("cTime", "i", $time, "<")->cond("cSessId", "s", $this->mSessId, "!=")->execute();
     }
 }
コード例 #2
0
ファイル: Storage.php プロジェクト: IMPHP/libimphp
 public function __construct(string $protocol = null)
 {
     if ($protocol !== null) {
         $this->mConnection = Database::newInstance($protocol);
     } else {
         $this->mConnection = Database::getInstance();
     }
     if ($this->mConnection === null || !$this->mConnection->isConnected()) {
         throw new Exception("Could not connect to the database '{$protocol}'");
     }
     if (mt_rand(0, 100) == 100) {
         $time = time();
         $this->mConnection->delete("cache")->cond("cExpires", "i", time(), "<")->cond("cExpires", "i", 0, ">")->execute();
     }
 }
コード例 #3
0
ファイル: User.php プロジェクト: IMPHP/libimphp
 public function getGroups() : ImmVector
 {
     if ($this->mUserGroups === null) {
         if ($this->isLoggedIn() && Database::isConnected()) {
             $result = Database::select("groups", "g")->join("usergroups", "u", "u.cGroupId", "g.cId")->field("g.cIdentifier")->cond("u.cUserId", "i", $this->mUserId)->enquire();
             if ($result !== null) {
                 $groups = [];
                 if ($result->numRows() > 0) {
                     while ($row = $result->fetch()) {
                         $groups[] = $row[0];
                     }
                 }
                 $result->destroy();
                 $this->mUserGroups = new ImmVector($groups);
             }
         } else {
             $this->mUserGroups = new ImmVector();
         }
     }
     return $this->mUserGroups;
 }