Gets the module instance from the database and returns it.
If no module instance exists this function returns false.

@return stdClass|bool
770948
private function get_mod_instance($cmid) {
        global $DB;
        $rec = $DB->get_record_sql("SELECT md.name
                               FROM {course_modules} cm,
                                    {modules} md
                               WHERE cm.id = ? AND
                                     md.id = cm.module", array($cmid));

        if ($rec) {
            return get_coursemodule_from_id($rec->name, $cmid);
        } else {
            return null;
        }
    }
412
public static function getInstance ()
    {
        // If this class is used for multiple singletons, we need to keep
        // track of multiple singleton objects, one for each class name
        static $instances = array();

        // Get class name to use. Use late static binding here,
        // if method is overriden by derived classes.
        $singletonClassName = static::_getInstanceClassName();

        // If already instantiated, use that
        if (isset($instances[$singletonClassName])) {
            return $instances[$singletonClassName];
        }

        // Otherwise create new instance
        $instances[$singletonClassName] = new $singletonClassName (static::_getInstanceFuseValue());

        return $instances[$singletonClassName];
    }
866005
public static function getDatabase()
    {
        $attribute = 'database';

        if (!static::hasClassAttribute($attribute)) {
            $database = Database::getDefault();

            if (!$database) {
                $error = static::error('connection', 'database not found', 'required-for', 6);
                switch (static::getClassConfig('error-mode')) {
                    case 'silent': break;
                    case 'exception': throw new Exception($error);
                    default: trigger_error($error, E_USER_ERROR);
                }
            }

            static::setClassAttribute($attribute, $database);
        }

        return static::getClassAttribute($attribute);
    }
1232213
public function get_context() {
        if ($this->itemtype == 'mod') {
            $modinfo = get_fast_modinfo($this->courseid);
            // Sometimes the course module cache is out of date and needs to be rebuilt.
            if (!isset($modinfo->instances[$this->itemmodule][$this->iteminstance])) {
                rebuild_course_cache($this->courseid, true);
                $modinfo = get_fast_modinfo($this->courseid);
            }
            // Even with a rebuilt cache the module does not exist. This means the
            // database is in an invalid state - we will log an error and return
            // the course context but the calling code should be updated.
            if (!isset($modinfo->instances[$this->itemmodule][$this->iteminstance])) {
                mtrace(get_string('moduleinstancedoesnotexist', 'error'));
                $context = \context_course::instance($this->courseid);
            } else {
                $cm = $modinfo->instances[$this->itemmodule][$this->iteminstance];
                $context = \context_module::instance($cm->id);
            }
        } else {
            $context = \context_course::instance($this->courseid);
        }
        return $context;
    }
640454
protected static function getInstance()
    {
        $type = self::getType();
        $appID = App::getCurrentID();
        $complementID = self::getCurrentID();
        $complement = get_called_class();
        if (! isset(self::$instances[$appID][$type][$complementID])) {
            self::$instances[$appID][$type][$complementID] = new $complement();
        }

        return self::$instances[$appID][$type][$complementID];
    }
207224
public static function instance()
    {
        if (empty(self::$databaseInstance)) {
            self::$databaseInstance = new static(self::$config);
        }
        return self::$databaseInstance;
    }
864796
public static function getInstance() {
        if( is_null(self::$_oInstance) ) {
            $c = __CLASS__;
            self::$_oInstance = new $c;
        }
        return self::$_oInstance;
    }
1219222
protected static function _instance($name = NULL)
	{
		if (!class_exists('Kohana_Database')) {
			throw new ErrorException('Kohana_Database module not loaded');
		}
		$name = static::instanceName($name);

		if (!array_key_exists($name, static::$transactions)) {
			static::$transactions[$name] = FALSE;
		}

		return Kohana_Database::instance($name);
	}
607624
public static function get($module) {
		if(self::$modules === array())
			self::initialize();

		if(!isset(self::$modules[$module]))
			return false;

		return self::$modules[$module];
	}
55230
public static function getInstance($instance)
	{
		$db = \App::get('db');

		if (empty($db)) {
			return false;
		}

		$hzph = new self();

		if (is_numeric($instance) && $instance > 0)
		{
			$hzph->user_id = $instance;
		}
		else
		{
			$query = "SELECT id FROM `#__users` WHERE username=" .  $db->quote($instance) . ";";
			$db->setQuery($query);
			$result = $db->loadResult();
			if (is_numeric($result) && $result > 0)
			{
				$hzph->user_id = $result;
			}
		}

		if (empty($hzph->user_id))
		{
			return false;
		}

		return $hzph;
	}
500273
public static function getInstance(  ) { 
            
        if(!self::$objInstance){ 
            self::$options = array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
            );
            
            self::$objInstance = new PDO(PDOLITE_DB_DSN, PDOLITE_DB_USER, PDOLITE_DB_PASS, self::$options); 
        } 
        
        return self::$objInstance; 
    }
918665
public static function instance()
    {
        if (empty(static::$_modmgr)) {
            $module = Yii::$app->getModule(static::$modulesManagerModuleUid);
            if (!empty($module) && $module instanceof UniModule) {
                static::$_modmgr = $module->getDataModel(static::$modulesManagerModelAlias);
            } else {
                static::$_modmgr = new static;
            }
        }
        return static::$_modmgr;
    }
859112
public static function get_course_module_by_instance($module, $instance) {

        $params = self::validate_parameters(self::get_course_module_by_instance_parameters(),
                                            array(
                                                'module' => $module,
                                                'instance' => $instance,
                                            ));

        $warnings = array();
        $cm = get_coursemodule_from_instance($params['module'], $params['instance'], 0, false, MUST_EXIST);

        return self::get_course_module($cm->id);
    }
1257397
private static function instance()
    {
        $currentClass = get_called_class();
        $instanceName = empty( self::$instance ) ? '' : new \ReflectionClass(self::$instance);
        if( empty( self::$instance ) || ( $instanceName->name != $currentClass ) ) {
            self::$instance = new static();
        }
        return self::$instance;
    }
1162234
public static function getInstance()
    {
        // set strict to false
        // -> meaning: no matter which parameter given we return the same instance
        self::$strict = false;

        // get possible parameter passed to this class
        $arguments = func_get_args();

        // decide call-type by given parameter
        if (empty($arguments)) {
            $instance = parent::getInstance();
        } else {
            $instance = parent::getInstance($arguments);
        }

        // return instance
        return $instance;
    }
77734
public function getModule()
    {
        if (!is_null(self::$module)) {
            return self::$module;
        }
        $controllerParam = array_get($this->routeParams, 'controller');
        $match           = null;
        preg_match('/(.*?)(?=@|$)/', $controllerParam, $match);
        if (!isset($match[0])) {
            return;
        }
        $reflection = new ReflectionClass($match[0]);
        $filename   = $reflection->getFileName();
        if (!preg_match("'antares(.*?)src'si", $filename, $match)) {
            return;
        }
        $reserved     = [
            'components', 'modules'
        ];
        self::$module = (str_contains($match[1], 'core')) ? 'core' : trim(str_replace($reserved, '', $match[1]), DIRECTORY_SEPARATOR);
        return self::$module;
    }
111542
public static function db()
    {
        if (self::$db === null) {
            $rc = rcube::get_instance();
            $db = rcube_db::factory($rc->config->get('db_dsnw'));

            $db->set_debug((bool)$rc->config->get('sql_debug'));

            // Connect to database
            $db->db_connect('w');

            if (!$db->is_connected()) {
                rcube::raise_error("Error connecting to database: " . $db->is_error(), false, true);
            }

            self::$db = $db;
        }

        return self::$db;
    }