Reputation: 163
I need to use a query which perfectly works in MySql. and query is
SELECT * FROM c2cxdb.jobs where job_title like '%Java%' and job_policy = 'Public' and job_status = 1;
where I need to replace java inside %% with a dynamic value that I pass to the method.
function AllJobs($job_title){
$allJobs = DB:: select('select * FROM c2cxdb.jobs where job_title like '%$job_title%' and job_policy = "Public" and job_status = 1');
dd($allJobs);
}
But It shows Division by zero exception when I run it.How to replace the value in my query with the value I Pass.I need to get the $job_title value into query.
Upvotes: 2
Views: 294
Reputation: 1390
function AllJobs($job_title){
$job_title="%".$job_title."%";
$allJobs = DB:: select('select * FROM c2cxdb.jobs where job_title like "'.$job_title.'" and job_policy = "Public" and job_status = 1');
dd($allJobs);
}
Upvotes: 0
Reputation: 2025
function AllJobs($job_title){
$allJobs = DB:: select('select * FROM c2cxdb.jobs where job_title like "%'.$job_title.'%" and job_policy = "Public" and job_status = 1');
dd($allJobs);
}
Upvotes: 1