Loader
in package
CodeIgniter resource loader utility class.
Provides static methods for loading models, libraries, databases, and configuration files with extended query builder support.
Table of Contents
Methods
- config() : mixed
- Load and retrieve a configuration value.
- database() : DB|null|false
- Load a database connection.
- library() : void
- Load one or more libraries into the CI instance.
- model() : void
- Load one or more models into the CI instance.
Methods
config()
Load and retrieve a configuration value.
public
static config(string $configFile[, string|null $itemName = null ]) : mixed
Results are cached after the first load.
Parameters
- $configFile : string
-
Configuration file name (without .php extension).
- $itemName : string|null = null
-
Specific item to retrieve. Null returns all items.
Return values
mixed —Configuration value, or empty string if item not found.
database()
Load a database connection.
public
static database([mixed $config = 'default' ][, bool $return = false ][, mixed $queryBuilder = null ][, bool $overwrite = false ]) : DB|null|false
Parameters
- $config : mixed = 'default'
-
Connection group name or configuration array. Default is "default".
- $return : bool = false
-
Return the DB instance instead of assigning to CI. Default is false.
- $queryBuilder : mixed = null
-
Custom query builder instance override.
- $overwrite : bool = false
-
Overwrite existing CI DB instance. Default is false.
Return values
DB|null|false —DB object if $return is true, false if already loaded, null otherwise.
library()
Load one or more libraries into the CI instance.
public
static library(string|array<string|int, string>|null $libraries) : void
Parameters
- $libraries : string|array<string|int, string>|null
-
Library name or array of library names.
model()
Load one or more models into the CI instance.
public
static model(string|array<string|int, string>|null $models) : void
Parameters
- $models : string|array<string|int, string>|null
-
Model name or array of model names.