/** * 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; }
/** * @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; }
/** * @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; }