| 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
{
/**
* 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
}
/**
* 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 $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();
}
/**
* 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();
}
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;
}
}