CodeIgniter Quick Reference

Some of useful functions but not all the time use. Will be a quick reference everytime want to use them.

URI segment

http://example.com/index.php/news/local/metro/crime_is_up
$this->uri->segment(3); //will produce: metro

DB SQL

$query = $this->db->query("YOUR QUERY");

if ($query->num_rows() > 0)
{
        foreach ($query->result() as $row)
        {
                echo $row->title;
                echo $row->name;
                echo $row->body;
        }
}
$this->db->select('title, content, date');
$this->db->from('blogs');
$this->db->join('comments', 'comments.id = blogs.id');
$this->db->where('name !=', $name);
$this->db->where('title', $title);
$query = $this->db->get('mytable');

end

Leave a Reply

Your email address will not be published. Required fields are marked *