Created
January 15, 2020 12:26
-
-
Save cwicaksono/7ab216500665cea05c9e32f8a6ff7b1c to your computer and use it in GitHub Desktop.
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
<?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