Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Rameshwar-ghodke/b19b3339837a1399330e9492c9b7de29 to your computer and use it in GitHub Desktop.
Save Rameshwar-ghodke/b19b3339837a1399330e9492c9b7de29 to your computer and use it in GitHub Desktop.
// insert into stud table value using codegnitor
$data = array(
'roll_no' => ‘1’,
'name' => ‘Virat’
);
$this->db->insert("stud", $data);
// Update query using codegnitor
$data = array(
'roll_no' => ‘1’,
'name' => ‘Virat’
);
$this->db->set($data);
$this->db->where("roll_no", ‘1’);
$this->db->update("stud", $data);
// Delete using codegnitor
$this->db->delete("stud", "roll_no = 1");
//Use the following code to get all the records from the database.
// The first following statement fetches all the records from “stud” table and returns the object,
which will be stored in $query object.
//The second statement calls the result() function with $query object to get all the records as array.
as -
$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->db->close(); // close the connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment