Skip to content

Instantly share code, notes, and snippets.

@Relequestual
Created February 19, 2012 22:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Relequestual/1866240 to your computer and use it in GitHub Desktop.
Save Relequestual/1866240 to your computer and use it in GitHub Desktop.
CodeIgniter blog_model pisyek tut
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog_model extends CI_Model {
function __construct() {
parent::__construct();
//var_dump(get_instance()); exit;
// $CI = get_instance();
// $CI->load->database();
//$this->load->libray('email');
}
function get_all_posts() {
$CI = get_instance();
$CI->load->database();
//$query = $this->db->get('entry');
$query = $CI->db->get('entry');
return $query->result();
}
function add_new_entry($name,$body) {
$data = array(
'entry_name' => $name,
'entry_body' => $body
);
$this->db->insert('entry', $data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment