codeigniter tutorial

CodeIgniter Method Chaining

In CodeIgniter, method chaining enables us to connect multiple method calls in single statement. Method chaining simplifies the syntax required to call multiple methods sequential over single object. Each of the method returns an object, without requiring intermediate variables to hold the results. Method chaining reduces the amount of code and improves the readability of code.

Example:- Let’s say you have a MySQL table named ’employee_master’ with the following fields 
emp_ID, emp_name, emp_email, emp_phone, emp_address, emp_code and emp_dept

$this->db->select('emp_name')->from('employee_master')->where('emp_ID', $id)->limit(10, 20);
$query = $this->db->get();