Tutorial by Examples

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 sec...
Selecting data with condition $query = $this->db->select('*') ->from('table_name') ->where('column_name', $value) // Condition ->get(); return $query->result(); Selecting data with multiple conditions $conditions =...
Usually we are not using second parameter in select([$select = '*'[, $escape = NULL]]) in CodeIgniter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names. In the following example, we are going to select the datetime type field by formatting it using sql query an...
Sometimes we need to join multiple tables to get aggregate data in return. here is how we can achieve the same using CodeIgniter Query Builder / Active Records. public function getStudentInfo($studentid){ $query = $this->db->select("st.id, st.name, st.class, mk.maths, mk.science&quo...

Page 1 of 1