$requestFields = $lh->getRequestFields(); $stmt .= "select " . implode(', ', $requestFields) . " from {$fromClause}"; $stmt .= $sWhere; $stmt .= $sOrder; $stmt .= " limit {$start}, {$length}"; if (false !== ($res = QuickPdo::fetchAll($stmt, $markers))) { $ret['data'] = []; foreach ($res as $k => $row) { $row = ['DT_RowId' => $row['id']] + $row; $ret['data'][$k] = $row; } } // recordFiltered $stmtCountFiltered = "select count(*) as count from {$fromClause}"; $stmtCountFiltered .= $sWhere; if (false !== ($info = QuickPdo::fetch($stmtCountFiltered, $markers))) { $ret['recordsFiltered'] = (int) $info['count']; } } } } catch (\Exception $e) { $ret['error'] = MeredithSupervisor::inst()->translate("Oops! An error occurred, please retry later"); MeredithSupervisor::inst()->log("Oops! An error occurred, please retry later: {$stmt} -- " . $e->getMessage()); } } } else { throw new MeredithException("Permission not granted to access rows with {$formId}"); } } else { throw new \Exception("An error occurred"); // but we don't care
<?php //------------------------------------------------------------------------------/ // DISPLAY EVENT INFO FROM THE DATABASE IN JSON FORMAT //------------------------------------------------------------------------------/ use QuickPdo\QuickPdo; use Tim\TimServer\TimServer; use Tim\TimServer\TimServerInterface; require_once __DIR__ . "/../../init.php"; require_once __DIR__ . "/../../functions/db.php"; TimServer::create()->start(function (TimServerInterface $server) { if (isset($_POST['id'])) { $stmt = 'select * from the_events where id=:id'; $eventInfo = QuickPdo::fetch($stmt, ['id' => $_POST['id']]); $server->success($eventInfo); } })->output();
<?php require_once __DIR__ . "/../../../../init.php"; use Meredith\Exception\MeredithException; use Meredith\Supervisor\MeredithSupervisor; use QuickPdo\QuickPdo; use Tim\TimServer\TimServer; use Tim\TimServer\TimServerInterface; TimServer::create()->start(function (TimServerInterface $server) { if (isset($_POST['formId']) && isset($_POST['id'])) { $id = (int) $_POST['id']; $view = (string) $_POST['formId']; if (true === MeredithSupervisor::inst()->isGranted($view, 'fetch')) { if (false !== ($info = QuickPdo::fetch("select * from {$view} where id={$id}"))) { $server->success($info); } else { $server->error(MeredithSupervisor::inst()->translate("An error occurred with the database, please retry later")); } } else { throw new MeredithException("Permission not granted to access rows with {$view}"); } } else { $server->error(MeredithSupervisor::inst()->translate("Invalid data")); } })->output();