/** * Executes a prepared statement. * * @param array $parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. * @return bool Returns true on success or false on failure. */ public function execute($parameters = []) { // increment query count $this->db->incrementQueryCount(); // run parent function return parent::execute((array) $parameters); }
/** * Boot session module. * * @param Application $application Calling application. * @return self */ public function boot(Application $application = null) : Module { // calling the session module without any application makes no sense if (isset($application) === false) { throw new ModuleException('The session module is expected to run within an application.'); } // try to get database module try { $database = $application->getContainer()->get('JohnnyOS\\Modules\\Database'); } catch (ContainerException $e) { return $this; } // database content is not quite usable if (is_callable($database) && ($database = $database()) instanceof Database === false) { return $this; } // everything is perfect, try to initialize session $this->instance = new DatabaseSession($database, new GenericRequest()); // start session $this->instance->start(); return $this; }
/** * The garbage collector. * * The garbage collector callback is invoked internally by PHP periodically * in order to purge old session data. The frequency is controlled by * session.gc_probability and session.gc_divisor. The value of lifetime * which is passed to this callback can be set in session.gc_maxlifetime. * * @param int $maxLifetime Max session lifetime. * @return bool */ public function gc($maxLifetime) { // delete all old sessions $this->db->exec("DELETE FROM `%prefix%sessions`\n WHERE `lastActionAt` < " . (time() - $maxLifetime) . "\n LIMIT 1000;"); return true; }