- 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
Union Get Method
The union_get
method for getting result from Union Query Builder.
Basic Usage
Here is the basic usage union_get
method from $db
property on SENE_Model class.
$this->db->union_get([bool $is_debug = 0]]): mixed
Parameters
This method has 1 optional parameters.
$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 union_get
in a model class.
<?php
class Blog_Model extends SENE_Model{
public $table = 'd_blog';
public $table_alias = 'b';
public function __construct(){
parent::__construct();
$this->db->from($this->table,$this->table_alias);
}
public function searchByScore($keyword){
$this->db->union_flush();
//1st union
$this->db->select('id');
$this->db->select('title');
$this->db->select('excerpt');
$this->db->select('date_modified');
$this->db->select_as("3",'score');
$this->db->from($this->table,$this->table_alias);
$this->db->where('title',$keyword,'or','like',1,0);
$this->db->where('excerpt',$keyword,'or','like',0,1);
$this->db->union_create();
//2nd union
$this->db->select('id');
$this->db->select('title');
$this->db->select('excerpt');
$this->db->select('date_modified');
$this->db->select_as("2",'score');
$this->db->from($this->table,$this->table_alias);
$this->db->where('title',$keyword,'or','like%',1,0);
$this->db->where('excerpt',$keyword,'or','like%',0,1);
$this->db->union_create();
//2nd union
$this->db->select('id');
$this->db->select('title');
$this->db->select('excerpt');
$this->db->select('date_modified');
$this->db->select_as("1",'score');
$this->db->from($this->table,$this->table_alias);
$this->db->where('title',$keyword,'or','%like',1,0);
$this->db->where('excerpt',$keyword,'or','%like',0,1);
$this->db->union_create();
//3nd union
$this->db->select('id');
$this->db->select('title');
$this->db->select('excerpt');
$this->db->select('date_modified');
$this->db->select_as("0",'score');
$this->db->from($this->table,$this->table_alias);
$this->db->where('title',$keyword,'or','%like%',1,0);
$this->db->where('excerpt',$keyword,'or','%like%',0,1);
$this->db->union_create();
$this->db->union_select('id,title,date_modified,score','score');
$this->db->union_group_by('id');
$this->db->union_order_by('score','desc')->union_limit(1, 14);
return $this->db->union_get();
}
}