Created
July 4, 2012 16:19
-
-
Save jrvaja/3048123 to your computer and use it in GitHub Desktop.
CodeIgniter: CI_InsertData_Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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