- 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
- putThemeContent
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Core Model
Core Model class is the feature of Seme Framework that allowed SENE_Model
to be extended or customized like add some methods or some properties.
When do I use this?
Use this feature when you need globally available methods for each class, e.g. model class.
Enable the Core Model
For enabling the core class, simply edit the Seme Framework Configuration files and then put the class model file inside app/core
.
Editing the Configuration
Lets say, the prefix of core class is ji_
and then the core controller class is model
.
...
/********************************/
/* == Core Configuration == */
/* register your core class, and put it on: */
/* - app/core/ */
/* all var $core_* value in lower case string*/
/* @var string */
/****************************/
$core_prefix = 'ji_';
$core_controller = '';
$core_model = 'model';
...
The JI_Model.php
file
On this example, we will add protected __encrypt
method to JI_Model
class for achieving database column encryption.
Also we have to add protected __decrypt
method to JI_Model
class for data decryption.
Do not forget to add __construct
method, because they are required from SENE_Model
abstract class.
Save the file under app/core/ji_model.php
.
<?php
class JI_Model extends SENE_Model
{
public function __construct()
{
parent::__construct();
}
/**
* Generates encryption command
* @param [type] $val [description]
* @return [type] [description]
*/
protected function __encrypt($val)
{
return 'AES_ENCRYPT('.$this->db->esc($val).',"'.$this->db->enckey.'")';
}
/**
* Generates decryption command
* @param [type] $key [description]
* @return [type] [description]
*/
protected function __decrypt($key)
{
return 'AES_DECRYPT('.$key.',"'.$this->db->enckey.'")';
}
}
How to use
While creating model class, extends the model class from JI_Model
class, not with SENE_Model
class.
<?php
class A_ApiKey_Model extends JI_Model{
var $tbl = 'a_apikey';
var $tbl_as = 'aak';
public function __construct(){
parent::__construct();
$this->db->from($this->tbl,$this->tbl_as);
}
...
public function get(){
$this->db->select('nation_code')
->select('id')
->select_as($this->__decrypt("$this->tbl_as.str"), "str", 0)
->select('is_active');
$this->db->from($this->tbl,$this->tbl_as);
$this->db->where("is_active",1);
return $this->db->get('',0);
}
...
}