| 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/indoasiaholidays.com/application/admin/models/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : CRUD.php
* File Desc. : CRUD Model
* Created By : Ranvir Singh <twitter @ranvir2012>
* Created Date : 23-05-2017
* Updated Date : 28-06-2017
*
* ************************************************************* */
class Admin_Model_CRUD extends Zend_Db_Table_Abstract {
function init() {
$this->db = Zend_Db_Table::getDefaultAdapter();
}
/**
* rv_create() method is used to add insert into database
* @param tablename , array
* @return inserted id
*/
public function rv_insert($tablename, array $addData) {
$dbtable = new Zend_Db_Table($tablename);
return $dbtable->insert($addData); // return inserted id
}
// public function rv_insert_footer($tablename, array $addData)
// {
// $dbtable = new Zend_Db_Table($tablename);
// return $dbtable->insert($addData); // return inserted id
// }
/**
* rv_update() method is used to edit
* @param table name, array data, where array
* @return true
*/
public function rv_update($tablename, array $editData, array $where) {
$dbtable = new Zend_Db_Table($tablename);
return $dbtable->update($editData, $where); // return row effected or not
}
/**
* delete() method is used to add menu
* @param array
* @return true
*/
public function rv_delete($table, $where) {
$dbtable = new Zend_Db_Table($table);
return $dbtable->delete($where);
}
/**
* rv_select_all() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function rv_select_all($tablename, array $columns, array $where, array $order, $limit = false) {
$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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('LongJsonInfo LIKE ?', "%$title%");
}
if (isset($this->searchArrP) && !empty($this->searchArrP)) {
$title = $this->searchArrP['Name'];
$select->where('LongJsonInfo LIKE ?', "%$title%");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function rv_select_destination_all($tablename, array $columns) {
$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($limit){
// $select->limit($limit);
// }
// echo $select;
// die('here');
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
/**
* rv_select_all() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function rv_select_all_custom_query($tablename, array $columns, array $where, $whereCustom, array $order, $limit = false) {
$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 (!empty($whereCustom)) {
$select->where("$whereCustom");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($limit) {
$select->limit($limit);
}
// echo $select;
// die('here');
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function selectOne($tablename, array $columns, array $where) {
//echo "hello";die;
$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");
}
}
$result = $dbtable->fetchRow($select);
return $result;
}
/**
* rv_select_row() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
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);
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;
$result = $dbtable->fetchRow($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
/**
* rv_select_row_where_custom() method is used to get all listing
* @param table name, columns array, where array, order array
* @return array result set
*/
public function rv_select_row_where_custom($tablename, array $columns, array $where, $whereCustom, array $order, $limit = false) {
$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 (!empty($whereCustom)) {
$select->where("$whereCustom");
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($limit) {
$select->limit($limit);
}
// echo $select;
// die('here');
$result = $dbtable->fetchRow($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function getCmsdata($tablename, array $columns, array $where, array $order) {
$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");
}
//echo $select; die;
$result = $dbtable->fetchRow($select);
return $result;
}
/**
* rv_rowExists() method is used to check state name exists or not in db
* @param table name, columns array, where array, order array
* @return array result set
*/
public function rv_rowExists($tablename, array $columns, array $where, array $order) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$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");
}
$result = $dbtable->fetchOne($select);
return $result;
}
public function getDestinations($where, $order = [], $limit = null) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tb_tbb2c_destinations as tbl", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.sid", ['title as region_name']);
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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
if ($limit) {
$select->limit($limit);
}
// echo $select;
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_activitie_custom_query($where) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = "SELECT Image,IsFeatured,PkgSysId FROM tb_tbb2c_packages_master tb1 WHERE ( 3 ) =
( SELECT COUNT( tb2.PkgSysId )
FROM tb_tbb2c_packages_master tb2
WHERE tb2.PkgSysId >= tb1.PkgSysId
AND (tb2.GTXPkgId ='$where[GTXPkgId]') AND (tb2.ItemType ='$where[ItemType]')
)
AND (tb1.IsActive='0') AND (tb1.IsMarkForDel='1') AND (tb1.IsPublish='0')";
$result = $dbtable->fetchAll($select);
if ($result == NULL) {
return false;
} else {
return $result;
}
}
public function getInternationalDestination($tablename, array $columns, $limit = false) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => $tablename), $columns)
->where("a.IsActive=?", 1)
->where("a.IsFeatured=?", 1)
->where("a.IsPublish=?", 1)
->where("a.IsMarkForDel=?", 0)
->where("a.CountryIds !=?", 101);
if ($limit) {
$select->limit($limit);
}
//echo $select;
$result = $dbtable->fetchAll($select);
return $result;
}
public function getInternationalDestinationAll($tablename, array $columns, $limit = false) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => $tablename), $columns)
->where("a.IsActive=?", 1)
->where("a.IsMarkForDel=?", 0)
->where("a.CountryIds !=?", 101)
->where("a.region_id !=?", 74);
if ($limit) {
$select->limit($limit);
}
//echo $select;
$result = $dbtable->fetchAll($select);
return $result;
}
public function getCount($tablename, array $where, $Id) {
$dbtable = new Zend_Db_Table($tablename);
$select = $dbtable->select()->from("$tablename as tbl", [$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 rv_select_all_package($tablename, array $columns, array $where) {
$page = isset($this->searchArr['page']) ? intval($this->searchArr['page']) : 1;
$rows = isset($this->searchArr['rows']) ? intval($this->searchArr['rows']) : 10;
$sort = isset($this->searchArr['sort']) ? $this->searchArr['sort'] : 'PkgSysId';
$order = isset($this->searchArr['order']) ? $this->searchArr['order'] : 'DESC';
$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 (isset($this->searchArr) && !empty($this->searchArr)) {
//
// $title = $this->searchArr['Destinations'];
// $select->where('tbl.Destinations LIKE ?', "%$title%");
// }
if (isset($this->searchArr) && !empty($this->searchArr)) {
$GTXPkgId = $this->searchArr['GTXPkgId'];
$select->where('tbl.GTXPkgId LIKE ?', "%$GTXPkgId%");
if (isset($this->searchArr['Destinations']) && !empty($this->searchArr['Destinations'])) {
$title = $this->searchArr['Destinations'];
$select->where('tbl.Destinations LIKE ?', "%$title%");
}
if (isset($this->searchArr['GTXPkgId']) && !empty($this->searchArr['GTXPkgId'])) {
$GTXPkgId = $this->searchArr['GTXPkgId'];
$select->where('tbl.GTXPkgId LIKE ?', "%$GTXPkgId%");
}
if (isset($this->searchArr['Title']) && !empty($this->searchArr['Title'])) {
$Title = $this->searchArr['Title'];
$select->where('tbl.LongJsonInfo LIKE ?', "%$Title%");
}
if (isset($this->searchArr['name']) && !empty($this->searchArr['name'])) {
$Title = $this->searchArr['name'];
$select->where('tbl.LongJsonInfo LIKE ?', "%$Title%");
}
}
if (count($order)) {
$select->order("$sort $order");
}
if ($rows) {
$select->limit($rows, $offset);
}
$result = $dbtable->fetchAll($select);
if ($result == NULL)
return false;
else
return $result->toArray();
}
public function getDestinationsIndex($where, $order = []) {
$page = isset($this->searchArr['page']) ? intval($this->searchArr['page']) : 1;
$rows = isset($this->searchArr['rows']) ? intval($this->searchArr['rows']) : 10;
$offset = ($page - 1) * $rows;
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tb_tbb2c_destinations as tbl", ['DesSysId', 'IsActive', 'Title', 'IsFeatured', 'Countries', 'Activities', 'Tours', 'Hotels', 'Image', 'Bannerimg', 'DisplayOnFooter','DisplayOnHeader']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.region_id AND tb2.IsMarkForDel = '0'", ['title as region_name']);
if (count($where)) {
foreach ($where as $k => $v) {
$select->where("$k =?", "$v");
}
}
if (!empty($this->searchArr)) {
if ($this->searchArr['Title'] != "") {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
if ($this->searchArr['Countries'] != "") {
$title = $this->searchArr['Countries'];
$select->where('tbl.Countries LIKE ?', "%$title%");
}
if ($this->searchArr['Region'] != "") {
$title = $this->searchArr['Region'];
$select->where('tb2.title LIKE ?', "%$title%");
}
}
if (count($order)) {
foreach ($order as $k => $v)
$select->order("$k $v");
}
if ($rows) {
$select->limit($rows, $offset);
}
$result = $dbtable->fetchAll($select);
return $result;
}
public function getBuyHotelCityAutoSuggest($keyword) {
$keyword = trim($keyword);
$response = array();
$rowset = $this->getCityListWithCountryDetail($keyword);
$respon = array();
if (count($rowset) > 0) {
foreach ($rowset as $row) {
$response[] = array('CityId' => $row['CityId'], 'CityName' => stripslashes($row['cityTitle']), 'label' => $row['cityTitle'] . '(' . $row['Country'] . ')', 'countryTitle' => trim($row['Country']));
}
}
return $response;
}
public function getCityListWithCountryDetail($where) {
// $country = array('ContId','Title as countryTitle','Code as countryCode');
$city = array('CityId', 'TBBCityId', 'Title as cityTitle', 'Alias as cityAlias', 'Country');
$select = $this->db->select();
$select->from(array('tbl' => "tb_master_geo_city"), $city);
//$select->joinInner(array('tb2' => "tb_master_geo_city"), "tbl.GTXCityId = tb2.CityId");
$select->where($where);
$select->where("tbl.IsActive = ?", 1);
$select->where("tbl.IsApproved = ?", 1);
$select->where("tbl.IsMarkForDel = ?", 0);
//$select->where("tb2.IsActive = ?", 1);
//echo $select;die;
$result = $this->db->fetchAll($select);
return $result;
}
public function mk_select_all_destination_data($keyword) {
$dataarray = array('DesSysId', 'Title','Image');
$select = $this->db->select();
$select->from(array('tbl' => "tb_tbb2c_destinations"), $dataarray);
$select->where("tbl.Title LIKE ?", "%$keyword%");
$select->where("tbl.IsActive = ?", 1);
$select->where("tbl.IsMarkForDel = ?", '0');
$result = $this->db->fetchAll($select);
return $result;
}
public function getYoutubeVideoId($iframeCode) {
return preg_replace_callback('/<iframe\s+.*?\s+src=(".*?").*?<\/iframe>/', function ($matches) {
// Remove quotes
$youtubeUrl = $matches[1];
$youtubeUrl = trim($youtubeUrl, '"');
$youtubeUrl = trim($youtubeUrl, "'");
// Extract id
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $youtubeUrl, $videoId);
return $youtubeVideoId = isset($videoId[1]) ? $videoId[1] : "";
}, $iframeCode);
}
public function mk_select_all_blog_data($keyword) {
$select = $this->db->select();
$select->from(array('tbl' => "tbl_blog"));
$select->where("tbl.category_name LIKE ?", "%$keyword%");
$select->where("tbl.status = ?", 1);
$select->where("tbl.isMarkForDel = ?", '0');
$select->order("tbl.BlogId DESC");
$result = $this->db->fetchAll($select);
return $result;
}
public function getDestinationsInd($where, $order = [], $limit = null) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tb_tbb2c_destinations as tbl", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.sid", ['title as region_name']);
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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
$select->where("tbl.Countries ='India'");
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchAll($select);
return $result;
}
public function getDestinationsInt($where, $order = [], $limit = null,$CountryIds = null) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tb_tbb2c_destinations as tbl", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.sid", ['title as region_name']);
//echo $CountryIds;die;
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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
if(!empty($CountryIds)){
$select->where("tbl.CountryIds !=?", $CountryIds);
// $select->where("tbl.CountryIds !=?", $CountryIds);
$select->where("tbl.Countries !='India'");
}
if ($limit) {
$select->limit($limit);
}
// echo $select;exit;
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_package_for_multi_ids() {
}
public function getDestinationsHeader($where, $order = [], $limit = null) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tb_tbb2c_destinations as tbl", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.region_id", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','region_id as region_id1']);
//$select->joinLeft(array('tb3' => "tbl_all_continent"), "tbl.ContinentId = tb3.ContinentId", ['*']);
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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchAll($select);
return $result;
}
public function getContinentRegionHeader() {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_all_continent as tb1", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tb1.ContinentId = tb2.ContinentId AND tb2.displayOnHeader = '1'", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','countryIds','countries']);
$select->joinLeft(array('tb3' => "tbl_countries"), "tb2.region_id = tb3.region_id AND tb3.displayOnHeader = '1'", ['title as countryTitle','countryId']);
//$select->joinLeft(array('tb4' => "tbl_states"), "tb2.region_id = tb4.region_id AND tb4.displayOnHeader = '1'", ['title as stateTitle','StateSysId']);
//$select->joinLeft(array('tb5' => "tb_tbb2c_destinations"), "tb2.region_id = tb5.region_id", ['Title as cityTitle']);
$select->where("tb1.status = ?", '1');
$select->where("tb2.IsActive = ?", 1);
$select->where("tb2.IsMarkForDel = ?", '0');
$result = $dbtable->fetchAll($select);
return $result;
}
// public function getCountryNameById($ids) {
//
// $whereCondition = " tb1.IsMarkForDel = '0'";
// $whereCondition .= " AND (tb1.CountryIds IN (".$ids.") )";
//
//
// $select->from(array('tb1' => "tb_tbb2c_destinations"), array('countries'));
// $select->where($whereCondition);
// $select->order("tb1.CountryIds DESC");
// $result = $dbtable->fetchAll($select);
// return $result;
// }
public function getDestinationAutoSuggest($keyword) {
$keyword = trim($keyword);
$response = array();
$rowset = $this->getDestinationListDetail($keyword);
$respon = array();
if (count($rowset) > 0) {
foreach ($rowset as $row) {
// $response[] = array('CityId' => $row['CityId'], 'CityName' => stripslashes($row['cityTitle']), 'label' => $row['cityTitle'],'countryTitle' => trim($row['Country']));
$response[] = array('DesSysId' => $row['DesSysId'], 'DesName' => stripslashes($row['Title']), 'label' => $row['Title']);
}
}
return $response;
}
public function getDestinationListDetail($where){
// $country = array('ContId','Title as countryTitle','Code as countryCode');
$city=array('Title','DesSysId','region_id');
$select = $this->db->select();
$select->from(array('tbl' => "tb_tbb2c_destinations") ,$city);
//$select->joinInner(array('tb2' => "tb_master_geo_city"), "tbl.GTXCityId = tb2.CityId");
$select->where($where);
$select->where("tbl.IsActive = ?", 1 );
$select->where("tbl.IsMarkForDel = ?", 0 );
// echo $select;die;
$result = $this->db->fetchAll($select);
return $result;
}
public function getCountryAutoSuggest($keyword) {
$keyword = trim($keyword);
$response = array();
$rowset = $this->getCountryListDetail($keyword);
// echo "<pre>";print_r($rowset);die;
$respon = array();
if (count($rowset) > 0) {
foreach ($rowset as $row) {
// $response[] = array('CityId' => $row['CityId'], 'CityName' => stripslashes($row['cityTitle']), 'label' => $row['cityTitle'],'countryTitle' => trim($row['Country']));
$response[] = array('DesSysId' => $row['DesSysId'], 'DesName' => stripslashes($row['Title']), 'label' => $row['Title']);
}
}
return $response;
}
public function getCountryListDetail($where){
// $country = array('ContId','Title as countryTitle','Code as countryCode');
$city=array('title as Title','countryId as DesSysId','region_id');
$select = $this->db->select();
$select->from(array('tbl' => "tbl_countries") ,$city);
//$select->joinInner(array('tb2' => "tb_master_geo_city"), "tbl.GTXCityId = tb2.CityId");
$select->where($where);
$select->where("tbl.IsActive = ?", '1' );
$select->where("tbl.IsMarkForDel = ?", '0' );
// echo $select;die;
$result = $this->db->fetchAll($select);
return $result;
}
public function rv_select_all_destinationByIds($table,$columns,$where,$idsColumn,$ids){
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from($table." as tb1", $columns);
if (count($where)) {
foreach ($where as $k => $v)
$select->where("$k =?", "$v");
}
$select->where('tb1.'.$idsColumn.' IN (' . $ids . ')');
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_continent() {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_all_continent as tb1", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tb1.ContinentId = tb2.ContinentId", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','countryIds','countries']);
//echo $select;die;
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_countries() {
$page = isset($this->searchContArr['page']) ? intval($this->searchContArr['page']) : 1;
$rows = isset($this->searchContArr['rows']) ? intval($this->searchContArr['rows']) : 10;
$offset = ($page - 1) * $rows;
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_countries as tb1", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tb1.region_id = tb2.region_id AND tb2.IsMarkForDel = '0'", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','countryIds','countries']);
$select->where("tb1.IsMarkForDel = ?", '0');
if (isset($this->searchContArr) && !empty($this->searchContArr)) {
$title = $this->searchContArr['title'];
$select->where('tb1.title LIKE ?', "%$title%");
}
if ($rows) {
$select->limit($rows, $offset);
}
//$select->where("tb2.IsMarkForDel = ?", '0');
$select->order("tb1.title ASC");
// echo $select;die;
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_states() {
$page = isset($this->searchStateArr['page']) ? intval($this->searchStateArr['page']) : 1;
$rows = isset($this->searchStateArr['rows']) ? intval($this->searchStateArr['rows']) : 10;
$offset = ($page - 1) * $rows;
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_states as tb1", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tb1.region_id = tb2.region_id AND tb2.IsMarkForDel = '0'", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','countryIds','countries']);
$select->joinLeft(array('tb3' => "tbl_countries"), "tb1.CountryIds = tb3.countryId AND tb3.IsMarkForDel = '0' AND tb3.seotitle != 'bhutan'", ['title as countryName']);
$select->where("tb1.IsMarkForDel = ?", '0');
if (isset($this->searchStateArr) && !empty($this->searchStateArr)) {
$title = $this->searchStateArr['title'];
$select->where('tb1.title LIKE ?', "%$title%");
}
if ($rows) {
$select->limit($rows, $offset);
}
//$select->where("tb2.IsMarkForDel = ?", '0');
$select->order("tb1.title ASC");
// echo $select;die;
$result = $dbtable->fetchAll($select);
return $result;
}
public function rv_select_all_regions() {
$page = isset($this->searchRegionArr['page']) ? intval($this->searchRegionArr['page']) : 1;
$rows = isset($this->searchRegionArr['rows']) ? intval($this->searchRegionArr['rows']) : 10;
$offset = ($page - 1) * $rows;
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_regions as tb1", ['*']);
$select->where("tb1.IsMarkForDel = ?", '0');
if (isset($this->searchRegionArr) && !empty($this->searchRegionArr)) {
$title = $this->searchRegionArr['title'];
$select->where('tb1.title LIKE ?', "%$title%");
}
if ($rows) {
$select->limit($rows, $offset);
}
//$select->where("tb2.IsMarkForDel = ?", '0');
$select->order("tb1.UpdateDate DESC");
// echo $select;die;
$result = $dbtable->fetchAll($select);
return $result;
}
public function checkCountryData($tablename,$id) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => $tablename))
->where("a.countryId = ?", $id);
$result = $dbtable->fetchAll($select);
return $result;
}
public function checkRegionData($tablename,$id) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => $tablename))
->where("a.region_id = ?", $id);
$result = $dbtable->fetchAll($select);
return $result;
}
public function checkStateData($id) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => "tbl_states"))
->where("a.stateId = ?", $id);
$result = $dbtable->fetchAll($select);
return $result;
}
public function checkCityData($id) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $this->db->select()
->from(array("a" => "tb_tbb2c_destinations"))
->where("a.DesId = ?", $id);
$result = $dbtable->fetchAll($select);
return $result;
}
public function getStatesHeader($where, $order = [], $limit = null) {
$dbtable = Zend_Db_Table::getDefaultAdapter();
$select = $dbtable->select()->from("tbl_states as tbl", ['*']);
$select->joinLeft(array('tb2' => "tbl_regions"), "tbl.region_id = tb2.region_id", ['title as region_name','label as region_label','Keyword','Description','Metatag','image as region_image','region_id as region_id1']);
//$select->joinLeft(array('tb3' => "tbl_all_continent"), "tbl.ContinentId = tb3.ContinentId", ['*']);
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 (isset($this->searchArr) && !empty($this->searchArr)) {
$title = $this->searchArr['Title'];
$select->where('tbl.Title LIKE ?', "%$title%");
}
if ($limit) {
$select->limit($limit);
}
$result = $dbtable->fetchAll($select);
return $result;
}
}