0) { $this->db->insert($tableName, $tableData); return $this->db->insert_id(); } return false; } /* get the data to table * $tableName -> Name of the table * $whereData -> Array -> where fields * $showField -> Array -> what are the fields need to show * */ public function selectTable($tableName, $whereData = array(), $showField = array('*'), $order = '') { $this->db->select($showField); $this->db->from($tableName); if (!empty($whereData) > 0) { $this->db->where($whereData); } if ($order != '') { $this->db->order_by($order,"DESC"); } /*if (count($limit>0)) { //$this->db->limit($limit[0],$limit[1]);//example $limit[0] = "0,10" where 0 is for offset and 10 for limit }*/ $query = $this->db->get(); return $query; } /* update the data to table * $tableName -> Name of the table * $whereData -> Array -> where fields * $updateData -> Array -> updated fields and data * */ public function updateTable($tableName, $whereData = array(), $updateData = array()) { $this->db->where($whereData); $this->db->update($tableName, $updateData); $return = $this->db->affected_rows() > 0; return $return; //$query->result_array(); //$query->num_rows(); } /* update the data to table * $tableName -> Name of the table * $whereData -> Array -> where fields * $updateData -> Array -> updated fields and data * */ public function deleteTableData($tableName, $whereData = array()) { // Insert the user record if (isset($whereData) && count($whereData) > 0) { $insert_id = $this->db->delete($tableName, $whereData); return true; } return false; } }