145 lines
3.6 KiB
PHP
Executable File

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Test_model extends CI_model {
function __construct() {
parent::__construct();
$this->load->database();
}
function name_list(){
$this->db->order_by('id', 'DESC');
$query = $this->db->get('master_cg_skills');
return $query->result();
}
function save_name($post) {
$slot_name = $post['slot_name'];
$data = array(
'name' => $slot_name,
);
$this->db->insert('master_cg_skills', $data);
}
function delete_name($id)
{
$this->db->where('id', $id);
$this->db->delete('master_cg_skills');
}
function edit_name($post,$id){
$data = array(
'name' => $post['slotEditname'],
);
$this->db->where('id', $id);
$this->db->update('master_cg_skills', $data);
}
function duplicate_entry($post)
{
$val = $post['val'];
if (isset($post['currId'])) {
$currId = $post['currId'];
$query1 = $this->db->get_where('master_cg_skills', array('id' => $currId));
$exceptVal = $query1->result()[0]->name;
// SELECT * FROM `master_cg_skills` WHERE name='12Hours' AND name!='vatibra'
$this->db->where('name', $val);
$this->db->where('name !=', $exceptVal);
$query = $this->db->get('master_cg_skills');
}
else{
$query = $this->db->get_where('master_cg_skills', array('name' => $val));
}
if($query->num_rows() > 0)
{
return 'exist';
}
else{
return 'notexist';
}
}
function status_change($post){
$id = $post['id'];
$stat = $post['val'];
$this->db->set('status', $stat);
$this->db->where('id', $id);
$this->db->update('master_cg_skills');
if($stat == '1')
{
return 'Status set active';
}
else{
return 'Status set deactive';
}
}
function getWherevalue($id){
$this->db->where('id', $id);
$query = $this->db->get('master_cg_skills');
return $query->result();
}
function getNameBysearch($search,$orderColumn, $orderType) {
if($orderColumn==0)
$this->db->order_by('id', $orderType);
else if($orderColumn==1)
$this->db->order_by('name', $orderType);
else if($orderColumn==2)
$this->db->order_by('status', $orderType);
$this->db->like('id', $search);
$this->db->or_like('name', $search);
$this->db->or_like('status', $search);
$query = $this->db->get('master_cg_skills');
return $query->result();
}
function getNameByLimit($limit, $start, $orderColumn, $orderType) {
if($orderColumn==0)
$this->db->order_by('id', $orderType);
else if($orderColumn==1)
$this->db->order_by('name', $orderType);
else if($orderColumn==2)
$this->db->order_by('status', $orderType);
$this->db->limit($limit, $start);
$query = $this->db->get('master_cg_skills');
return $query->result();
}
function getNameByLimitBySearch($limit, $start, $search) {
$this->db->like('id', $search);
$this->db->order_by('id', 'desc');
$this->db->or_like('name', $search);
$this->db->or_like('status', $search);
$this->db->limit($limit, $start);
$query = $this->db->get('master_cg_skills');
return $query->result();
}
}