- Seme Framework
- version 4.0.3
- Requirements
- Download & Install
- Configuration
- Tutorials
- URI Routing
- Constants
- Global Variables
- Model
- View
- Controller
- cdn_url
- config
- constructor
- getAdditional
- getAdditionalBefore
- getAdditionalAfter
- getAuthor
- getCanonical
- getContentLanguage
- getDescription
- getIcon
- getJsContent
- getJsFooter
- getJsReady
- getKey
- getKeyword
- getLang
- getRobots
- getShortcutIcon
- getThemeElement
- getTitle
- input
- lib
- load
- loadCss
- loadLayout
- putThemeContent
- putJsContent
- putJsFooter
- putJsReady
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Load Method
The load
method purpose purpose is for loading a Model Class by generating (instantiating) a new property inside current controller class.
The new property name will be same as model filename without .php
extension in lowercase.
Basic Usage
Here is the basic usage load
method from SENE_Controller class.
$this->load(string $model_filename [, string $alias]): void
Parameters
This method has 1 required parameter and 1 optional parameter.
$model_filename
The $model_filename
value can be contain a string of model filename.
File location always relatives to app/model
directory.
So, if we have a model class under app/model/api/hello_model.php
We have to fill the first parameter with extra suffix path, like api/hello_model
.
$alias
The $alias
value can be contain a string that override the name of property that instantiated by this method.
Example
On this example, will show the implementation of load
method without an alias.
<?php
class Blog extends SENE_Controller {
public function __construct(){
parent::__construct();
$this->load('hello_model');
}
public function index(){
//executing the hello_model object
print_r($this->hello_model->get());
die();
}
}
With Alias
On this example, will show the implementation of load
method with an alias.
<?php
class Blog extends SENE_Controller {
public function __construct(){
parent::__construct();
$this->load('api/hello_model','hm');
}
public function index(){
//executing the hello_model object
print_r($this->hm->get());
die();
}
}
Inside a Directory
On this example, will show the implementation of load
method loading a model inside a directory and without an alias.
<?php
class Blog extends SENE_Controller {
public function __construct(){
parent::__construct();
$this->load('api/hello_model');
}
public function index(){
//executing the hello_model object
print_r($this->hello_model->get());
die();
}
}