Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function FIND_IN_SET() not working in codeigniter

Tags:

codeigniter

The function FIND_IN_SET() works on local but not working on the server.when I load company_by_category_model by calling controller(controller name) then it throws an error

Error:

FUNCTION firstdial.FIND_IN_SET does not exist

SELECT * FROM (`company_information`, `user_information`) 
WHERE `FIND_IN_SET` ('16',company_category) 
AND company_information.allowstatus=1 
AND company_information.delstatus=0 
AND company_information.user_id=user_information.user_id 
ORDER BY `company_id` desc

Filename: C:\wamp\www\firstdial\system\database\DB_driver.php
Line Number: 331

Code:

function company_by_category_model($category_id)
{   
    $this->db->select('*');
    $this->db->from('company_information,user_information');
    $search="FIND_IN_SET ('$category_id',company_category) 
        AND company_information.allowstatus=1 
        AND company_information.delstatus=0 
        AND company_information.user_id=user_information.user_id";
    $this->db->where($search);
    $this->db->order_by('company_id','desc');
    $query=$this->db->get();
    return $query->result();
}
like image 210
Support Techcherry Avatar asked Nov 05 '16 11:11

Support Techcherry


2 Answers

You must always check the results from the FIND_IN_SET() function somehow to make it work, try this:

  $this->db->where("FIND_IN_SET('$value',employer_job_location) !=", 0);
like image 104
Rana Ghosh Avatar answered Nov 15 '22 03:11

Rana Ghosh


function company_by_category_model($category_id)
{
    $this->db->select('*');
    $this->db->from('company_information,user_information');
    $search="FIND_IN_SET ('".$category_id."',company_category) 
        AND company_information.allowstatus=1 
        AND company_information.delstatus=0 
        AND company_information.user_id=user_information.user_id";
    $this->db->where($search);
    $this->db->order_by('company_id','desc');
    $query=$this->db->get();
    return $query->result();
}

Try removing single quote from $category_id this is variable

like image 38
Mukul Bhardwaj Avatar answered Nov 15 '22 04:11

Mukul Bhardwaj