| Server IP : 101.53.144.229 / Your IP : 216.73.216.181 Web Server : Apache System : Linux host.gdigitalindia.in 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : digitalshiksha ( 1179) PHP Version : 5.6.40 Disable Function : eval,show_source,system,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,show_source,curl_multi_exechellcmd, ini_restore,apache_get_modules,get_cfg_var,passthru, exec ,proc_get_status,fpassthru,c999_buff_prepare,c999_sess_put,c99_buff_prepare,c99_sess_put,proc_close,ini_alter,dl,symlink,link,proc_close,ini_alter,dl,symlink,link,mail MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/digitalshiksha/public_html/application/models/ |
Upload File : |
<?php
#[\AllowDynamicProperties]
class Product_model extends CI_Model
{
public function getdata($field = NULL, $value = NULL)
{
$this->load->database();
if ($field != NULL && $value != NULL) {
$this->db->where('status', 1);
// $where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($field, $value);
}
$query = $this->db->get('product');
return $query->result_array();
}
public function activate($table = NULL, $link = NULL)
{
if ($table == "users" || $table == "reviews") {
$this->db->set('status', 1);
$this->db->where('id', $link);
$this->db->update($table);
} else {
$this->db->set('status', 1);
$this->db->where('link', $link);
$this->db->update($table);
}
}
public function deactivate($table = NULL, $link = NULL)
{
if ($table == "users") {
$this->db->set('status', 2);
$this->db->where('id', $link);
$this->db->update($table);
} else if ($table == "reviews") {
$this->db->set('status', 0);
$this->db->where('id', $link);
$this->db->update($table);
} else {
$this->db->set('status', 0);
$this->db->where('link', $link);
$this->db->update($table);
}
}
public function delete($table = NULL, $link = NULL)
{
if ($table == "reviews" || $table == "brands" || $table == "blog" ) {
$this->db->where('id', $link);
$this->db->delete($table);
return true;
}else {
$this->db->where('link', $link);
$this->db->delete($table);
return true;
}
}
public function search($keyword, $data = NULL)
{
$query = "SELECT * FROM product WHERE name like '%$keyword%' or category like '%$keyword%' or category like '%$keyword%' and status = 1";
if ($data != NULL) {
if($data == 'price_desc'){
$query .= "
ORDER BY price DESC";
}
else if($data == 'price_asc'){
$query .= "
ORDER BY price ASC";
}
if($data == 'id_desc'){
$query .= "
ORDER BY id DESC";
}
else if($data == 'id_asc'){
$query .= "
ORDER BY id ASC";
}
}
$result = $this->db->query($query);
return $result->result_array();
}
public function insert($data = array())
{
$insert = $this->db->insert('product', $data);
return $insert ? true : false;
}
public function get_category($link)
{
$query = $this->db->get_where('category', array('link' => $link));
if ($query->num_rows() > 0) {
return $query->row();
} else {
return 0;
}
}
public function getmaincategories()
{
$this->db->where('parent', "");
$query = $this->db->get('category');
return $query->result_array();
}
public function checkcategory($link)
{
$query = $this->db->get_where('category', array('link' => $link));
if ($query->num_rows() > 0) {
return 1;
} else {
return 0;
}
}
public function checkblog($link)
{
$query = $this->db->get_where('blog', array('link' => $link));
if ($query->num_rows() > 0) {
return 1;
} else {
return 0;
}
}
}