%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
Class Blog_Model extends CI_Model{
protected $table_name = 'SH_Blogs';
protected $primary_key = 'BlogID';
protected $order_by = 'BlogPriorityOrder DESC';
protected $fields = 'BlogID, BlogTitle, BlogContent, BlogThumbnail, BlogPoster, BlogExcerpt,
BlogBanner, BlogPriorityOrder, BlogURL, Status';
Public function __construct()
{
parent::__construct();
}
function home_blogs(){
return $this->db2->query("SELECT *
FROM `wp_posts` AS p
INNER JOIN `wp_postmeta` AS pm1 ON p.id = pm1.post_id
INNER JOIN `wp_postmeta` AS pm2 ON pm1.meta_value = pm2.post_id
AND pm2.meta_key = '_wp_attached_file'
AND pm1.meta_key = '_thumbnail_id'
ORDER BY p.id DESC LIMIT 0,3")->result_array();
}
function get_article($id){
return $this->db->get_where($this->table_name, array($this->primary_key => $id))->row_array();
}
function get_article_by_slug($slug){
return $this->db->get_where($this->table_name, array('BlogURL' => $slug))->row_array();
}
function get_article_by_name($name){
return $this->db->get_where($this->table_name, array('BlogTitle' => $name))->result_array();
}
function article_title_exists($name){
$this->db->select('BlogID');
return $this->db->get_where($this->table_name, array('BlogTitle' => $name), 1)->result_array();
}
function article_slug_exists($slug){
$this->db->select('BlogID');
return $this->db->get_where($this->table_name, array('BlogURL' => $slug), 1)->result_array();
}
function get_all_articles($fields = '', $where = array(), $order_by = '', $status = '', $limit = ''){
if ($fields != '') {
$this->db->select($fields);
}
else{
$this->db->select($this->fields);
}
if($order_by != ''){
$this->db->order_by($order_by);
}
else{
$this->db->order_by($this->order_by);
}
if ($status != '') {
$this->db->where('Status', $status);
}
if (count($where)) {
$this->db->where($where);
}
if ($limit != ''){
$this->db->limit($limit);
}
$Query = $this->db->get($this->table_name);
$result = $Query->result_array();
$Query->free_result();
return $result;
}
function insert_article($data){
$data['CreationDate'] = $data['UpdationDate'] = date('Y-m-d H:i:s');
$success = $this->db->insert($this->table_name, $data);
if ($success) {
return $this->db->insert_id();
} else {
return FALSE;
}
}
public function update_article($data, $id) {
$data['UpdationDate'] = date('Y-m-d H:i:s');
$this->db->where($this->primary_key, $id);
return $this->db->update($this->table_name, $data);
}
public function delete_article($id) {
$this->db->where($this->primary_key, $id);
return $this->db->delete($this->table_name);
}
}
?>