codeigniter select query with multiple clauses – onlinecode

codeigniter select query with multiple clauses – onlinecode

In this post we will give you information about codeigniter select query with multiple clauses – onlinecode. Hear we will give you detail about codeigniter select query with multiple clauses – onlinecodeAnd how to use it also give you demo for it if it is necessary.

In this article, we will explain how to use a select query with multiple clauses in Codeigniter. The Codeigniter provides Active Record class and that class through we can get data from the database using a select query.

CodeIgniter Select Query Example

$this->db->select("*");
$this->db->from("users");
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with get where clause

$this->db->select("*");
$this->db->from("users");
$this->db->where('id',2);
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter Select Query with Multiple Where Clause

$this->db->select("*");
$this->db->from("users");
$this->db->where('id',1);
$this->db->where('first_name','test');
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Or Where clause

$this->db->select("*");
$this->db->from("users");
$this->db->or_where('first_name', 'test');
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Where In clause

$this->db->select("*");
$this->db->from("users");
$this->db->where_in('id',array(1,2));
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Where Not In clause

$this->db->select("*");
$this->db->from("users");
$this->db->where_not_in('id',array(1,2));
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Like clause

$this->db->select("*");
$this->db->from("users");
$this->db->like('first_name', 's', after);
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Limit clause

$this->db->select("*");
$this->db->from("users");
$this->db->limit(5, 10);
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Codeigniter select query with Join clause

You can refer to this URL for Codeigniter select query with join clause.

Codeigniter select query with Order By clause

$this->db->select("*");
$this->db->from("users");
$this->db->order_by('id', 'desc');
$objQuery = $this->db->get();
$data = $objQuery->result_array();

Please follow and like us:

Hope this code and post will helped you for implement codeigniter select query with multiple clauses – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

33  +    =  35

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US