I am trying to refactor a switch statement to a collection. The switch statement selects the correct SQL query to run based on the switch conditional.
The queries all have concatenations within the switch statement, which does not work in an array within a class. Here is an example query similar to what I am dealing with:
"select qqqq,wwww,eeee,rrrr,tttt, 'yyyy' as uuuu from " . CONSTANT . ".aaaa as ssss inner join ' . CONSTANT2 . '.ddddd .... etc.
Any suggestions?
EDIT
Here is something close to the actual code. I made some changes for privacy:
<?php
namespace Collections;
class ScheduleSQL {
private $sql;
public function __construct($plant)
{
$sql = [
'fgfghh' => "select fdgsgdfg, sgfdfgfg, rotary_priority,sfgfgfddg,sgfsgf, JB_ULT_CUST,jbr_status, jb_cust_want_date, routing_done, jb_date_need, js_time_ship, js_ship_via, jb_job_desc, rot.job_nbr, rot.job_plt, rot.job_type, sdfgdfgdf, js_ship_to, js_shipto_name, js_state, js_city, jbr_created as cvbvbv,xbvbvb, xbvbvb,xvbvbbcvb, vbvbvbas job_class, ruling_completed,scheduled_rule_date, converter, scenario_id, scenario_subdomain, transfer_type,transfer_job, jb_slope, jb_inch
from ' . DB_RASTER_LIB . 'jbraster as rot
inner join ' . DB_STR_LIB . '.sessions_and_jobs as str
on rot.job_type = str.job_type and str.jb_job = rot.job_nbr and cgc.jb_plt = rot.job_plt
inner join ' . DB_RASTER_LIB . '.rot_job_sp as rot_sp
on rot_sp.jb_job = str.jb_job and rot_sp.jb_plt = str.jb_plt and rot_sp.job_type = rot.job_type
left outer join ' . DB_RASTER_LIB . '.job_data as rot_jd
on rot_jd.job_nbr = str.jb_job and rot_jd.job_plt = str.jb_plt and rot_jd.job_type = rot.job_type
inner join ' . DB_STR_LIB . '.jobshp as shp
on str.jb_job = shp.js_job and str.jb_plt = shp.js_plt and shp.job_type = rot.job_type and shp.js_primary = 1
where rot.job_plt = $plant and rot.job_type <> A and (jbr_status is null or jbr_status<>99)
order by jb_date_need asc"
];
}
public function getSQL($type)
{
return $this->sql[$type];
}
}