| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/dcb/application/models/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : Cms.php
* File Description : Cms Model
* Created By : Nitesh Yadav
* Created Date: 03-october-2023
* ************************************************************* */
class Application_Model_Comments extends Zend_Db_Table_Abstract {
protected $_name = 'tbl_comments';
protected $db;
function __construct() {
$this->db = Zend_Db_Table::getDefaultAdapter();
}
public function add($addData = array()) {
$dbtable = new Zend_Db_Table('tbl_comments');
$addData['blog_id'] = $addData['blog_id'];
return $dbtable->insert($addData);
}
public function rv_select_all($tablename, array $columns, array $where, array $order) {
$page = isset($this->searchArr['page']) ? intval($this->searchArr['page']) : 1;
$rows = isset($this->searchArr['rows']) ? intval($this->searchArr['rows']) : 3;
$offset = ($page - 1) * $rows;
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k=?", "$v");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($rows) {
$select->limit($rows, $offset);
}
// echo $select; die(' dbc');
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function rv_select_row($tablename, array $columns, array $where, array $order) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", $columns);
// echo "<pre>";print_r($columns);die(' dcb');
if (count($where)) {
foreach ($where as $k => $v) {
$select->where("$k =?", "$v");
}
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
//echo $select; die(' dbc');
$result = $dbtable->fetchRow($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function getCount($tablename, array $where, $Id) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", array($Id => 'COUNT(*)'));
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k=?", "$v");
}
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function updateDisplayOnComment($commentId, $newValue) {
$dbtable = new Zend_Db_Table('tbl_comments');
$data = array('displayOnComment' => $newValue);
$where = array('id = ?' => $commentId);
$dbtable->update($data, $where);
}
public function mostPopularBlog($category = null) {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array("title", "description", "blogPageKey", "small_image", "mobile_small_image", "large_image", "createdOn as created_date"))
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name"));
if ($category) {
$select->where("t2.category_key =?", $category);
}
$select->where("t1.status =?", 'Activate');
$select->where("t2.status =?", 'Activate');
$select->where("t1.mostpopularblog =?", 1);
$select->order("t1.id DESC");
$result = $this->db->fetchAll($select);
return $result;
}
public function categoryBanner($category) {
$select = $this->db->select()
->from("tbl_category", array("category_banner", "mobile_banner", "category_name"));
if ($category) {
$select->where("category_key = ?", $category);
}
$result = $this->db->fetchRow($select);
return $result;
}
public function recentBlog($category = null) {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array("title", "description", "blogPageKey", "small_image", "mobile_small_image", "large_image", "createdOn as created_date"))
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name"));
if ($category) {
$select->where("t2.category_key =?", $category);
}
$select->where("t1.status =?", 'Activate');
$select->where("t2.status =?", 'Activate');
$select->order("t1.id DESC");
$select->limit(12);
$result = $this->db->fetchAll($select);
return $result;
}
public function getCategory() {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array())
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name", "cat_order", "id", "category_key"))
->where("t1.category_id > 0")
->where("t1.status =?", 'Activate')
->where("t2.status =?", 'Activate')
->group("category_name")
->order("t2.cat_order")
->limit(5);
$result = $this->db->fetchAll($select);
return $result;
}
public function getCategoryIndividual() {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array())
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name", "cat_order", "id", "category_key"))
->where("t1.category_id > 0")
->where("t1.status =?", 'Activate')
->where("t2.status =?", 'Activate')
->group("category_name")
->order("t2.cat_order");
$result = $this->db->fetchAll($select);
return $result;
}
public function allBlog($category = null) {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array("title", "category_id", "description", "blogPageKey", "small_image", "mobile_small_image", "large_image", "createdOn as created_date"))
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name", "category_key"));
if ($category) {
$select->where("t2.category_name =?", $category);
}
$select->where("t1.status =?", 'Activate');
$select->where("t2.status =?", 'Activate');
$select->order("t1.id DESC");
$result = $this->db->fetchAll($select);
return $result;
}
public function getNextCategoryList($currentCategoryList) {
$select = $this->db->select()
->from(array("t1" => "tbl_blog"), array())
->joinLeft(array('t2' => "tbl_category"), "t1.category_id = t2.id", array("category_name", "cat_order", "id", "category_key"))
->where("t1.category_id > 0")
->where("t1.status =?", 'Activate')
->where("t2.status =?", 'Activate')
->group("category_name")
->order("t2.cat_order")
->limit(100, 5);
// echo $select; exit;
$result = $this->db->fetchAll($select);
return $result;
}
}