function getSpecific() { $family = $_GET['family']; if (!isset($_GET['family'])) { throw new Exception("No se especifico [family]"); } date_default_timezone_set("America/Monterrey"); if (false) { echo file_get_contents(getFilename('specific')); } else { $query = file_get_contents('sql/specific.sql'); $DB = new MxOptix(); $DB->setQuery($query); $DB->bind_vars(':family', $family); $DB->exec(); echo $DB->json(); } }
function getDataFromOSFM($kpiid) { // return '20'; try { $results = null; $DB = new MxOptix(); $query = "SELECT Count(job) qty FROM apps.xxbi_cyp_activity_log_v@osfm\n WHERE ORGANIZATION_CODE = 'F07'AND item IN ({codes})\n AND systemdate_est BETWEEN To_Date(To_Char(SYSDATE-2,'yyyymmdd')||'0730','yyyymmddhh24mi') AND\n To_Date(To_Char(SYSDATE-1,'yyyymmdd')||'0730','yyyymmddhh24mi')AND OPERATION_TYPE = 'DONE'\n "; $query = str_replace("{codes}", getCodes($kpiid), $query); $DB->setQuery($query); oci_execute($DB->statement); oci_fetch_all($DB->statement, $results, 0, -1, OCI_FETCHSTATEMENT_BY_ROW); $DB->close(); return $results[0]['QTY']; } catch (Exception $e) { $DB->close(); echo 'Caught exception: \\n' . print_r($e) . "\n"; } }
function example() { try { $DB = new MxOptix(); global $app; $body = $app->request()->getBody(); $body = json_decode($body, true); // print_r($body); $DB->setQuery($body['query']); $results = null; oci_execute($DB->statement); oci_fetch_all($DB->statement, $results, 0, -1, OCI_FETCHSTATEMENT_BY_ROW); // print_r($results); // print_r($results); echo array2csv($results); $DB->close(); } catch (Exception $e) { $DB->close(); echo 'Caught exception: ' . $e->getMessage() . "\n"; } }