Select Method

Select method is part of database class builder for selecting column data into a table.

Parameters

Update method has 1 required parameters that is column name and value, another parameters are optional. Here is the completed parameters can be used by where methods

$this->db->select(string $column_name): dbObject

$column_name

Column Name can be single column name, or can be filled with wildcard "*".

Example usage

Here is the examples using select method. See the first of this page for full example.

Basic Usage

For example we assumed want to add new data in blog table. First, in the model:

class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
	 parent::__construct();
  }
  public function getList(){
    $this->db->select("*");
    $this->db->from($this->tbl,$this->tbl_as);
    return $this->db->get();
  }
  public function getById($id){
    $this->db->select("id");
    $this->db->select("title");
    $this->db->select("content");
    $this->db->from($this->tbl,$this->tbl_as);
    $this->db->where_as("id",$id);
    return $this->db->get_first();
  }
}

at the controller, we assumed has file named blog.php

class Blog extends Sene_Controller{
  public function __construct(){
    parent::__construct();
    $this->load('blog_model','bm'); #class scope model
  }
  public function index(){
    $blogs = $this->bm->getList();
    $this->debug($blogs);
  }
  public function detail($id){
    $blog = $this->bm->getById($id);
    $this->debug($blog);
  }
}