Skip to content

Instantly share code, notes, and snippets.

@cwicaksono
Created January 15, 2020 12:26
Show Gist options
  • Save cwicaksono/7ab216500665cea05c9e32f8a6ff7b1c to your computer and use it in GitHub Desktop.
Save cwicaksono/7ab216500665cea05c9e32f8a6ff7b1c to your computer and use it in GitHub Desktop.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Blogpost_model extends MY_Model {
protected $table = 'blogpost';
protected $key = 'id';
protected $soft_deletes = false;
protected $date_format = 'datetime';
protected $set_created = false;
protected $set_modified = false;
public function __construct()
{
parent::__construct();
}
public function getHome(){
$q = "select
blogpost.id,
blogpost.title,
blogpost.short_description,
blogpost.id_author,
blogpost.featured_image,
blogpost.created_on,
users.fullname as author
from
blogpost
inner join users on users.id = blogpost.id_author
order by blogpost.id desc
limit 0, 5
";
$query = $this->db->query($q)->result();
if(count($query) > 0){
return $query;
}else{
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment