403Webshell
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/vanguarddmc.com/application/admin/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/vanguarddmc.com/application/admin/models/CRUD.php
<?php
/***************************************************************
 * Catabatic Technology Pvt. Ltd.
 * File Name    : CRUD.php
 * File Desc.   : CRUD Model
 * Created By    : Piyush Tiwari <piyush@catpl.co.in>
 * Created Date : 23-05-2018
 * Updated Date : 28-06-2018
 * 
***************************************************************/



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(count($order)){
            foreach ($order as $k => $v)
            $select->order("$k  $v");
        }
        if($limit){
            $select->limit($limit);
        }
//        echo "<pre>" ;print_r($select); die();
        $result = $dbtable->fetchAll($select);
        if($result==NULL)
            return false;
        else
            return $result->toArray();
    }
    
    public function rv_select_blog_all($tablename, array $columns, array $where, array $order, $limit =false)
    {
        $dbtable = Zend_Db_Table::getDefaultAdapter();

        $select="SELECT * FROM tbl_travelogues p LEFT JOIN ( SELECT blogId, COUNT(*) as cc FROM tbl_comments as cn GROUP BY blogId ) x ON x.blogId = p.TravId where p.isMarkForDel = '0'";

        $result = $dbtable->fetchAll($select);

        if($result==NULL)
            return false;
        else
            return $result;
    }
    
    public function rv_select_blog_all_home($tablename, array $columns, array $where, array $order, $limit =false)
    {
        $dbtable = Zend_Db_Table::getDefaultAdapter();

        $select="SELECT * FROM tbl_travelogues p LEFT JOIN ( SELECT blogId, COUNT(*) as cc FROM tbl_comments as cn GROUP BY blogId ) x ON x.blogId = p.TravId where p.isMarkForDel = '0' and p.status = '1' and p.displayOnBanner = '1'";

        $result = $dbtable->fetchAll($select);
        
        if($result==NULL)
            return false;
        else
            return $result;
    }
    
    
        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();
    }

 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();
    }

    /**
    * 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 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", ['DesSysId','Title','Image','Tours']);

        $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 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.sid", ['title as region_name','label as region_label','image as region_image']);

        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);
//        echo"<pre>"; print_r($result);die();
        return $result;
    }

    public function getDestinationsForFooter($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);
        }

        $result = $dbtable->fetchAll($select);
        return $result;
    }
    
    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','DisplayOnHeader','IsActive','Title','IsFeatured', 'Countries', 'Activities', 'Tours', 'Hotels','Image','Bannerimg','DisplayOnFooter']);


        $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 (!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 getExpertCount($where, $order = [], $limit = null) {
        $dbtable = Zend_Db_Table::getDefaultAdapter();
        $select = $dbtable->select()->from("tbl_our_expert as tbl", ['ExpertId' => 'COUNT(*)']);

        $select->joinLeft(array('tb2' => "tbl_regions"), "tbl.ExpertDestination = tb2.sid", ['title as ExpertDestination']);

        if (count($where)) {
            foreach ($where as $k => $v)
                $select->where("$k =?", "$v");
        }

        $result = $dbtable->fetchAll($select);
        return $result;
    }

    public function getExpertIndex($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("tbl_our_expert as tbl", ['ExpertId', 'ExpertName', 'ExpertEmail', 'ExpertPhone', 'ExpertImage', 'status']);

        $select->joinLeft(array('tb2' => "tbl_regions"), "tbl.ExpertDestination = tb2.sid", ['title as ExpertDestination']);

        if (count($where)) {
            foreach ($where as $k => $v) {
                $select->where("$k =?", "$v");
            }
        }
        if (!empty($this->searchArr)) {
            if ($this->searchArr['ExpertDestination'] != "") {
                $title = $this->searchArr['ExpertDestination'];
                $select->where('tb2.title LIKE ?', "%$title%");
            }
            if ($this->searchArr['ExpertName'] != "") {
                $title = $this->searchArr['ExpertName'];
                $select->where('tbl.ExpertName LIKE ?', "%$title%");
            }
        }
        if (count($order)) {
            foreach ($order as $k => $v)
                $select->order("$k  $v");
        }
        if ($rows) {
            $select->limit($rows, $offset);
        }
//        echo $select;die;
        $result = $dbtable->fetchAll($select);
        return $result;
    }


    public function getTraveloguesIndex($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("tbl_travelogues as tbl", ['TravId', 'TravTitle','TravDestination', 'TravDate', 'TravDays', 'TravTraveller', 'TravUploadedBy', 'TravImage', 'TravBannerImage', 'status']);


        $select->joinLeft(array('tb2' => "tb_tbb2c_destinations"), "tb2.DesSysId = tbl.TravDestination" , ['title as TravDestination']);

        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.TravTitle LIKE ?', "%$title%");
            }
           
        }
        if (count($order)) {
            foreach ($order as $k => $v)
                $select->order("$k  $v");
        }
        if ($rows) {
            $select->limit($rows, $offset);
        }
//        echo $select;die;
        $result = $dbtable->fetchAll($select);
        return $result;
    }

     public function getpacktypeIndex($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("tbl_pack_type as tbl", ['packType', 'Title','Icon', 'IsActive']);


//        $select->joinLeft(array('tb2' => "tb_tbb2c_destinations"), "tb2.DesSysId = tbl.TravDestination" , ['title as TravDestination']);

        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 (count($order)) {
            foreach ($order as $k => $v)
                $select->order("$k  $v");
        }
        if ($rows) {
            $select->limit($rows, $offset);
        }
//        echo $select;die;
        $result = $dbtable->fetchAll($select);
        return $result;
    }

    
       public function getTestimonialIndex($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("tbl_testimonials as tbl", ['*']);


//        $select->joinLeft(array('tb2' => "tb_tbb2c_destinations"), "tb2.DesSysId = tbl.TravDestination" , ['title as TravDestination']);

        if (count($where)) {
            foreach ($where as $k => $v) {
                $select->where("$k =?", "$v");
            }
        }
            if (!empty($this->searchArr)) {
            if ($this->searchArr['name'] != "") {
                $title = $this->searchArr['name'];
                $select->where('tbl.name LIKE ?', "%$title%");
            }
           
        }
        if (count($order)) {
            foreach ($order as $k => $v)
                $select->order("$k  $v");
        }
        if ($rows) {
            $select->limit($rows, $offset);
        }
//        echo $select;die;
        $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 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_static($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']) : 10;
        $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)) {
            if (isset($this->searchArr['Title']) && !empty($this->searchArr['Title'])) {
            $title = $this->searchArr['Title'];
            $select->where('tbl.page_title LIKE ?', "%$title%");
            }
            if (isset($this->searchArr['Titles']) && !empty($this->searchArr['Titles'])) {
            $title = $this->searchArr['Titles'];
            $select->where('tbl.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);
        if ($result == NULL)

            return false;
        else
            return $result->toArray();
    }

    
      public function getFlightIndex($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("tbl_flight_booking as tbl", ['id', 'response', 'IsActive', 'CreatedDate']);

//        $select->joinLeft(array('tb2' => "tbl_regions"), "tbl.ExpertDestination = tb2.sid", ['title as ExpertDestination']);

        if (count($where)) {
            foreach ($where as $k => $v) {
                $select->where("$k =?", "$v");
            }
        }
        if (!empty($this->searchArr)) {
            if ($this->searchArr['bookingId'] != "") {
                $title = $this->searchArr['bookingId'];
                $select->where('tbl.response LIKE ?', "%$title%");
            }
           
        }
        if (count($order)) {
            foreach ($order as $k => $v)
                $select->order("$k  $v");
        }
        if ($rows) {
            $select->limit($rows, $offset);
        }
//        echo $select;die;
        $result = $dbtable->fetchAll($select);
        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 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 rv_select_promotion_all($table,$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($table, ['*']);

      
        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;
        $result = $dbtable->fetchAll($select);
        return $result;
    }
    
    public function getRegionImage($region){
        $dbtable = Zend_Db_Table::getDefaultAdapter();
        $select = "SELECT image from tbl_regions where label like '%$region%'";

        $result = $dbtable->fetchOne($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);
        if ($limit) {
            $select->limit($limit);
        }
        //echo $select;
        $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->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->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_region() {
         $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_regions as tb1", ['*']);
       $select->where("tb1.IsMarkForDel = ?", '0');
        
         if (isset($this->searchRegionsArr) && !empty($this->searchRegionsArr)) {
            $title = $this->searchRegionsArr['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 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 runMyQuery($sql) {
        return $this->db->query($sql)->fetch();
    }
     public function filterdestinamtionAction()
    {
        //Check admin logedin or not
      //  $this->checklogin();
        $status = false;
        $apiData = [];
        $apiData["AgencySysId"] = Catabatic_Helper::getAgencyId();
        $url = Catabatic_Helper::gtxBtoBsite();
        try {
            $curl = curl_init($url."gtxwebservices/createxml/package-destinations");
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            $curl_response = curl_exec($curl);
            
// send response to the view page
        
        
        $JSONFileName = "public/data/dynamic/package_destinations.json";
        file_put_contents($JSONFileName, $curl_response);
        
        $responseArray = Zend_Json::decode($curl_response);
       // echo "<pre>";print_r($responseArray);die('here');
        
        $crud   = new Admin_Model_CRUD();
        $resionArr = array();
         $countryArr = array();
        $resionResult  = $crud->rv_select_all("tbl_regions",['label'] ,  ['status'] , ['title'=>'ASC' ] );
        foreach ($resionResult as $resultkey => $resultvalue) {
            $resionArr[] = $resultvalue['label'];
        }
       
        $countryResult  = $crud->rv_select_all("tbl_countries",['label'] ,  ['status'] , ['title'=>'ASC' ] );
        foreach ($countryResult as $contkey => $contvalue) {
            $countryArr[] = $contvalue['label'];
        }
      
        $reasonInsertArray = array();
        $countryInsertArray = array();
        $stateInsertArray = array();
        $cityInsertArray = array();
        foreach ($responseArray as $resionkey => $resionvalue) {
    
            if($resionvalue['TypeTitle'] == 'region'){
                if (!in_array($resionvalue['label'], $resionArr)) {
               
            $reasonInsertArray = [
                'title' => $resionvalue['value'],
                'label' => $resionvalue['label'],
                'image' => '',
                'UpdateDate' => date('Y-m-d H:i:s'),
                'CreateDate' => date('Y-m-d H:i:s'),
                'IsActive' => 1,
                'IsMarkForDel' => 0,
            ];
             $resionArr[] = $resionvalue['label'];
             try {
                    $resionIDS[] = $crud->rv_insert('tbl_regions', $reasonInsertArray);
                } catch (Zend_Exception $e) {
                            echo "1----" . $e->getMessage();
                            exit;
                        }
             
            } 
            }
          
            if($resionvalue['TypeTitle'] == 'country'){
                if (!in_array($resionvalue['label'], $countryArr)) {
               
                $countryInsertArray = [
                    'title' => $resionvalue['value'],
                    'label' => $resionvalue['label'],
                    'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),
                    'countryId' => $resionvalue['id'],
                    'image' => '',
                    'region_id' => 0,
                    'UpdateDate' => date('Y-m-d H:i:s'),
                    'CreateDate' => date('Y-m-d H:i:s'),
                    'IsActive' => 1,
                    'IsMarkForDel' => 0,
                ];
                // echo "<pre>";print_r($resionvalue);die;
                 $countryArr[] = $resionvalue['label'];
                try {
                    $countryIDS[] = $crud->rv_insert('tbl_countries', $countryInsertArray);
                } catch (Zend_Exception $e) {
                            echo "2----" . $e->getMessage();
                            exit;
                        }
                 
                } 
            }
              
            if ($resionvalue['TypeTitle'] == 'state') {
                    $stateResult = $crud->checkStateData($resionvalue['id']);
                    if (count($stateResult) == 0) {
                        $stateInsertArray = [
                            'title' => $resionvalue['value'],
                            'label' => $resionvalue['label'],
                            'seotitle' => strtolower(Catabatic_Helper::getSeoName($resionvalue['value'])),
                            'stateId' => (int)$resionvalue['id'],
                            'CountryIds' => $resionvalue['ContId'],
                            'Countries' => $resionvalue['countryName'],
                            
                            'UpdateDate' => date('Y-m-d H:i:s'),
                            'CreateDate' => date('Y-m-d H:i:s'),
                            'IsActive' => 1,
                            'IsMarkForDel' => 0,
                        ];
                        try {
                            $crud->rv_insert('tbl_states', $stateInsertArray);
                        } catch (Zend_Exception $e) {
                            echo "3----" . $e->getMessage();
                            exit;
                        }
                    }
                }
                if ($resionvalue['TypeTitle'] == 'city') {
                    $cityResult = $crud->checkCityData($resionvalue['id']);
                    if (count($cityResult) == 0) {
                        $cityInsertArray = [
                            'Title' => $resionvalue['value'],
                            'DesId' => $resionvalue['id'],
                            'CountryIds' => $resionvalue['ContId'],
                            'Countries' => $resionvalue['countryName'],
                            'IsPublish'=>1,
                            'UpdateDate' => date('Y-m-d H:i:s'),
                            'CreateDate' => date('Y-m-d H:i:s'),
                            'IsActive' => 1,
                            'IsMarkForDel' => 0,
                        ];
                        try {
                            $crud->rv_insert('tb_tbb2c_destinations', $cityInsertArray);
                        } catch (Zend_Exception $e) {
                            echo "4----" . $e->getMessage();
                            exit;
                        }
                    }
                }
        }
        
         curl_close($curl);
            $this->view->errorMessage = ""; 
            $msg = $this->view->successMessage = "Filter destination successfully updated.";
            $status = true;
        } catch (Exception $error) {
            $status = false;
            $this->view->successMessage = "";
            $msg = $this->view->errorMessage = $error->getMessage();
           
        }
        $result = array('status'=>$status,'msg'=>$msg);
        return $result;
        // echo "<pre>";print_r($response_array);die('hhhh');
        
        
       
        
    }
	
        
}


Youez - 2016 - github.com/yon3zu
LinuXploit