| 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/tripsgateway/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(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;
}
}