- 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
Get Method
The get
method is a part of the query builder
which is useful for getting all results from the query builder that has been compiled.
Basic Usage
Here is the basic usage get
method from $db
property on SENE_Model class.
$this->db->get([string $result_type = "" [, bool $is_debug = 0]]): mixed
Parameters
This method has 2 optional parameters.
$result_type
The value of the $result_type
parameter to determine the output of the get method.
Fill with string "array"
to return the result value with data type array of array.
While the contents of other values to return values with data type array of objects.
$is_debug
The $is_debug
parameter is a marker (flag) to enable debug mode.
The value of this parameter can be filled with int 1
to enable debug mode and display the query to be processed.
Fill it with another value to not enable debug mode.
In debug mode, there will be no query execution process to the database system.
Example
Here is the example for get
in a model class.
class D_Blog_Model extends SENE_Model{
var $tbl = 'blog';
var $tbl_as = 'b';
public function __construct(){
parent::__construct();
}
...
public function getSearch($keyword){
$this->db->from($this->tbl,$this->tbl_as);
$this->db->where("title", ($keyword), "OR", "%like%", 1, 0);
$this->db->where("content", ($keyword), "AND", "%like%", 0, 1);
$this->db->where("is_published", $this->db->esc(1));
return $this->db->get();
}
...
}
SQL Result
The following is the SQL command that generated from D_Blog_Model
class methods.
-- result from executing D_Blog_Model::getSearch('Seme Framework') --
SELECT *
FROM `d_blog` b
WHERE
(
`title` LIKE '%Seme Framework%'
OR `content` LIKE '%Seme Framework%'
)
AND `is_published` = 1;