Gets a Medioteca Instance.
@param mixed $nb_medioteca A CNabuDataObject intance containing a field named 'nb_medioteca_id' or and ID.
@return mixed Returns the instance if exists or false if not.
554331
public function getMedioteca($nb_medioteca)
    {
        $nb_medioteca_id = nb_getMixedValue($nb_medioteca, NABU_MEDIOTECA_FIELD_ID);

        return is_numeric($nb_medioteca_id) || nb_isValidGUID($nb_medioteca_id)
               ? $this->nb_medioteca_list->getItem($nb_medioteca_id)
               : false
        ;
    }
1345072
public function setMediotecaItemId(int $nb_medioteca_item_id) : CNabuDataObject
    {
        if ($nb_medioteca_item_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_medioteca_item_id")
            );
        }
        $this->setValue('nb_medioteca_item_id', $nb_medioteca_item_id);
        
        return $this;
    }
608539
public function newItem(string $key = null)
    {
        $nb_medioteca_item = $this->isBuiltIn()
                           ? new CNabuBuiltInMediotecaItem()
                           : new CNabuMediotecaItem()
        ;
        $nb_medioteca_item->setKey($key);

        return $this->addItemObject($nb_medioteca_item);
    }
548684
public static function getDatabase()
	{
		//get the database settings from global space
        global $database;

        //create instance of database class
        $instance = new BaseDb($database['default'], $database[$database['default']]);

        //get connection instance and make attempt to connect to the database
        $instance = $instance->initialize()->connect();

		return $instance; 

	}
207224
public static function instance()
    {
        if (empty(self::$databaseInstance)) {
            self::$databaseInstance = new static(self::$config);
        }
        return self::$databaseInstance;
    }
779049
public function getDbConnection()
    {
        if (!Yii::app()->hasComponent($this->connectionID)) {
            throw new CException(sprintf('Connection component "%s" does not exist.', $this->connectionID));
        }
        $db = Yii::app()->getComponent($this->connectionID);
        if (!$db instanceof CDbConnection) {
            throw new CException(sprintf(
                'Connection component "%s" is not an instance of CDbConnection.',
                $this->connectionID
            ));
        }
        return $db;
    }
1197832
static function getInstance($databaseNameOrResource = '*LOCAL', $userOrI5NamingFlag = '', $password = '', $extensionPrefix = '', $isPersistent = false, $forceNew = false)
    {
        // if we're forcing a new instance, close db conn first if exists.
        if ($forceNew && self::hasInstance() && isset(self::$instance->conn))
        {
            self::$instance->disconnect();
        }

        // if we're forcing a new instance, or an instance hasn't been created yet, create one
        if ($forceNew || self::$instance == NULL) {
            $toolkitService = __CLASS__;
            self::$instance = new $toolkitService($databaseNameOrResource, $userOrI5NamingFlag, $password, $extensionPrefix, $isPersistent);
        }

        if (self::$instance) {
            // instance exists
            return self::$instance;
        } else {
            // some problem
            return false;
        }
    }
552344
public function getAdminUser($force = false) {

        if ($this->nb_admin_user === null || $force) {
            $this->nb_admin_user = null;
            if ($this->isValueNumeric('nb_server_admin_user_id')) {
                $nb_user = new CNabuUser($this->getAdminUserId());
                if ($nb_user->isFetched()) {
                    $this->nb_admin_user = $nb_user;
                }
            }
        }

        return $this->nb_admin_user;
    }
1322545
public static function getInstance($table = null, $tablePrefix = null, $db = null)
    {
        static $mInstance = [];
        $class = get_called_class();
        $classKey = $class . '-' . $tablePrefix . $table;
        if (!isset($mInstance[$classKey])) {
            $mInstance[$classKey] = new $class();
            is_null($table) || $mInstance[$classKey]->table = $table;
            is_null($tablePrefix) || $mInstance[$classKey]->tablePrefix = $tablePrefix;
            is_null($db) || $mInstance[$classKey]->db = $db;
        }
        return $mInstance[$classKey];
    }
804472
static public function findByEMail($nb_customer, string $email)
    {
        $retval = null;

        if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID))) {
            $retval = CNabuUser::buildObjectFromSQL(
                'select u.* '
                . 'from nb_user u, nb_customer c '
               . 'where u.nb_customer_id=c.nb_customer_id '
                 . 'and c.nb_customer_id=%cust_id$d '
                 . 'and u.nb_user_email=\'%email$s\'',
                array(
                    'cust_id' => $nb_customer_id,
                    'email' => $email
                )
            );
            if ($retval instanceof CNabuUser && $nb_customer instanceof CNabuCustomer) {
                $retval->setCustomer($nb_customer);
            }
        }

        return $retval;
    }
1346103
public static function getCustomerUsedLanguages($nb_customer)
    {
        $nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID);
        if (is_numeric($nb_customer_id)) {
            $nb_language_list = CNabuLanguage::buildObjectListFromSQL(
                'nb_language_id',
                'select l.* '
                . 'from nb_language l, '
                     . '(select distinct nb_language_id '
                        . 'from nb_medioteca ca, nb_medioteca_lang cal '
                       . 'where ca.nb_medioteca_id=cal.nb_medioteca_id '
                         . 'and ca.nb_customer_id=%cust_id$d) as lid '
               . 'where l.nb_language_id=lid.nb_language_id',
                array('cust_id' => $nb_customer_id)
            );
        } else {
            $nb_language_list = new CNabuLanguageList();
        }
        
        return $nb_language_list;
    }
748708
protected function fetchObject()
	{
		if (!empty($this->cursor) && $this->cursor instanceof \PDOStatement)
		{
			return $this->cursor->fetchObject($this->class);
		}
		else
		{
			return false;
		}
	}
900416
public static function getDB($name = null)
    {
        if ($name === null) {
            $name = self::getDefaultDB();
        }

        if (!isset(self::$adapterMap[$name])) {
            if (!isset(self::$configuration['datasources'][$name]['adapter'])) {
                throw new PropelException("Unable to find adapter for datasource [" . $name . "].");
            }
            $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']);
            // register the adapter for this name
            self::$adapterMap[$name] = $db;
        }

        return self::$adapterMap[$name];
    }
806257
public static function getInstance()
    {
        if (!isset(self::$_instance)) {
            $c = __CLASS__;
            self::$_instance = new $c;
        }
        return self::$_instance;
    }
718609
public function getDBInstance()
    {
        if ($this->database === null) {
            $this->database = new MySQLDBImpl($this->config);
        }

        return $this->database;
    }
559102
public static function findByKey($nb_medioteca, $key)
    {
        $nb_medioteca_id = nb_getMixedValue($nb_medioteca, 'nb_medioteca_id');
        if (is_numeric($nb_medioteca_id)) {
            $retval = CNabuSiteTargetSection::buildObjectFromSQL(
                    'select * '
                    . 'from nb_site_target_section '
                   . 'where nb_medioteca_id=%medioteca_id$d '
                     . "and nb_site_target_section_key='%key\$s'",
                    array(
                        'medioteca_id' => $nb_medioteca_id,
                        'key' => $key
                    )
            );
        } else {
            $retval = null;
        }
        
        return $retval;
    }
1226702
public function getMediotecas($force = false)
    {
        if ($this->nb_medioteca_list->isEmpty() || $force) {
            $this->nb_medioteca_list->clear();
            $this->nb_medioteca_list->merge(CNabuMedioteca::getAllMediotecas($this));
        }

        return $this->nb_medioteca_list->getItems();
    }