Skip to content

Instantly share code, notes, and snippets.

@jrvaja
Created July 4, 2012 16:19
Show Gist options
  • Save jrvaja/3048123 to your computer and use it in GitHub Desktop.
Save jrvaja/3048123 to your computer and use it in GitHub Desktop.
CodeIgniter: CI_InsertData_Methods
/*
function getAll() {
$q = $this->db->query("SELECT * FROM data");
if($q->num_rows() > 0) {
foreach($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
*/
/*
function getAll() {
$q = $this->db->get('data');
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
*/
/*
function getAll() {
$this->db->select('title, contents');
$q = $this->db->get('data');
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
*/
/*
function getAll() {
$sql = "SELECT title, author, contents FROM data WHERE id = ? AND author = ?";
$q = $this->db->query($sql, array(2, 'Jeffrey Way'));
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
*/
function getAll() {
$this->db->select('title, contents');
$this->db->from('data');
$this->db->where('id', 1);
$q = $this->db->get();
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment