codeigniter Query Structure Selecting Data


Example

The following functions allow you to build SQL SELECT statements.

$this->db->get()

This runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:

$query = $this->db->get('tablename');  // Produces: SELECT * FROM tablename

The second and third parameters enable you to set a limit and offset clause:

$query = $this->db->get('tablename', 10, 20);

// Executes: SELECT * FROM tablename LIMIT 20, 10
// (in MySQL. Other databases have slightly different syntax)