/**
  * Garbage Collection, removes all the expired sessions
  *
  * @param int maxlifetime, after that the session will expire
  * @return boolean
  */
 public function gc($maxlifetime = 300)
 {
     $stmt = $this->conn->prepareStatement('DELETE FROM c_sessions WHERE `session_lastmodified` < ?');
     $stmt->setTimestamp(1, time() - $maxlifetime);
     $stmt->executeUpdate();
     return true;
 }
Пример #2
0
 /**
  * @todo can we use QueryBuilder for this?
  * Helper, internal method witch performs an sql query, other than select.
  *
  * @param string sql the sql query to execute
  * @return int affected rows
  * @throws SQLException
  */
 private function performQuery($sql)
 {
     $timer = new MTimer();
     $stmt = ActiveRecord::$conn->prepareStatement($sql);
     ActiveRecord::populateStmtValues($stmt, $this->getAffectedFields());
     $af_rows = $stmt->executeUpdate();
     $stmt->close();
     ActiveRecord::log($timer, $af_rows);
     return $af_rows;
 }
Пример #3
0
 /**
  * @todo can we use QueryBuilder for this?
  * Helper, internal method witch performs an sql query, other than select.
  *
  * @param string sql the sql query to execute
  * @return int affected rows
  * @throws SQLException
  */
 private function performQuery($sql)
 {
     $stmt = ActiveRecord::$conn->prepareStatement($sql);
     ActiveRecord::populateStmtValues($stmt, $this->getAffectedFields());
     $af_rows = $stmt->executeUpdate();
     $stmt->close();
     Registry::get('__logger')->debug('Query: ' . ActiveRecord::$conn->lastQuery);
     // $this->_reset();
     return $af_rows;
 }