I have three select boxes on a form that get their values from a database, and instead of making a request for each one, it would be far more efficient to make a single request and return all the options for all three select boxes at once.
I have looked into the new MixedConnector, but:
- I don’t seem to be able to get it to return data. I get no PHP errors, but nothing is generated.
- Even if I had it return data, I can’t find any documentation on how to get the select boxes to use the data returned from the MixedConnector. How would I do that?
Here’s the relevant code from my connector PHP file. The SQL queries are identical to the ones for the individual connectors, which work. The $connXXXXX->configure statements are identical in structure to the $data->render_sql statements for the individual connectors.
$sqlType = "SELECT '' AS TypeID, '' AS ReqType UNION ";
$sqlType .= "SELECT TypeID, ReqType ";
$sqlType .= "FROM ITRequests_Types";
$connType = new SelectOptionsConnector($mysqli, "MySQLi");
$connType->configure($sqlType,"TypeID","TypeID, ReqType");
$sqlTechs = "SELECT '' AS EmployeeID, '' AS Name UNION ";
$sqlTechs .= "SELECT Technicians.EmployeeID, CONCAT(FirstName,' ',LastName) AS Name ";
$sqlTechs .= "FROM Technicians ";
$sqlTechs .= "INNER JOIN Employee.EmployeeMaster ON Technicians.EmployeeID = EmployeeMaster.EmployeeID ";
$sqlTechs .= "WHERE TechType = 'Technician'";
$connTechs = new SelectOptionsConnector($mysqli, "MySQLi");
$connTechs->configure($sqlTechs,"EmployeeID","EmployeeID,Name");
$sqlStatus = "SELECT '' AS ReqStatusID, '' AS ReqStatus UNION ";
$sqlStatus .= "SELECT ReqStatusID, ReqStatus ";
$sqlStatus .= "FROM ITRequests_Statuses";
$connStatus = new SelectOptionsConnector($mysqli, "MySQLi");
$connStatus->configure($sqlStatus,"ReqStatusID","ReqStatusID, ReqStatus");
$connAll = new MixedConnector($mysqli, "MySQLi");
$connAll->add("types", $connType);
$connAll->add("technicians", $connTechs);
$connAll->add("statuses", $connStatus);
$connAll->render();