Advertisement
taktikhek

Untitled

Jun 24th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. class Blog_model extends CI_Model {
  3. function __construct() {
  4. parent::__construct();
  5. }
  6.  
  7. function get_all($number,$offset){
  8. $data = array();
  9. $this->db->select('*');
  10. $this->db->where('post.post_posting_by = admin.id_user');
  11. $this->db->where('post.post_category_id = post_category.post_category_id');
  12. $this->db->where('post.post_status = "Publish"');
  13. $this->db->order_by('post.post_id desc');
  14. $Q = $this->db->get('post, admin, post_category',$number,$offset);
  15.  
  16. if($Q->num_rows()>0){
  17. foreach ($Q->result_array() as $row) {
  18. $data[] = $row;
  19. }
  20. }
  21.  
  22. $Q->free_result();
  23. return $data;
  24. }
  25.  
  26. function jumlah_data(){
  27. return $this->db->get('post')->num_rows();
  28. }
  29.  
  30.  
  31. function get_detail_by_slug($slug){
  32. $data = array();
  33. $this->db->select('*');
  34. $this->db->where('post.post_posting_by = admin.id_user');
  35. $this->db->where('post.post_category_id = post_category.post_category_id');
  36. $this->db->where('post.post_slug', $slug);
  37. $Q = $this->db->get('post, admin, post_category');
  38.  
  39. if($Q->num_rows()>0){
  40. $data = $Q->row_array();
  41. }
  42.  
  43. $Q->free_result();
  44. return $data;
  45. }
  46.  
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement