- Seme Framework
- Credits
- Version 3.2.X
- Issue
- Deployment
Select AS Method
The select_as
method is part of Query Builder for selecting column data into a table with its aliases.
Basic Usage
Here is the basic usage select_as
method from $db
property on SENE_Model class.
$this->db->select_as(string $col_name, string $alias [, bool $is_esc=0]): $this->db
Parameters
Update method has 2 required parameters and 1 optional parameter.
$col_name
The $col_name
value can be a single column name or can be filled with wildcard "*", or can be filled with MySQL function.
$alias
The $alias
value can be a string that represent the selected column.
$is_esc
The $is_esc
value can be a boolean, if 1 all value are escaped otherwise unescaped.
Example
For the example we assumed want to select a colum in a table with select_as
method.
class Blog_Model extends SENE_Model{
var $tbl = 'blog';
var $tbl_as = 'b';
public function __construct(){
parent::__construct();
}
public function countPublished(){
$this->db->select_as("COUNT(*)","total",0);
$this->db->from($this->tbl,$this->tbl_as);
$this->db->where("is_published",$is_published);
return $this->db->get_first();
}
}