if (array_key_exists($c, $vars)) { $jc[] = $c; } } } $on = "{$table2}.{$jo[0]}={$table}.{$jo[0]}"; // Check Columns given, if not use SQL START if (empty($jc)) { $jc = Zend\Db\Sql\Select::SQL_STAR; } // Set Default join type $j_type = Zend\Db\Sql\Select::JOIN_LEFT; // Check join type specified if (!empty($join_type[$key])) { $types = array(Zend\Db\Sql\Select::JOIN_INNER, Zend\Db\Sql\Select::JOIN_OUTER, Zend\Db\Sql\Select::JOIN_LEFT, Zend\Db\Sql\Select::JOIN_RIGHT); if (in_array($join_type[$key], $types)) { $j_type = $join_type[$key]; echo $j_type; } } $dbh->join($table, $on, $jc, $j_type); $pre_joined_tables[$table] = true; } else { //echo "error at".$table.$table2; list_error(HTTP_Status::BAD_REQUEST); } } else { list_error(HTTP_Status::BAD_REQUEST); } } }
try { $dbh = new MyDbCon(); $dbh->select($_GET['master']); include "./joins.php"; $filepath = "./custom/{$_GET['master']}.get.php"; if (file_exists($filepath)) { require_once $filepath; } else { require_once "./common.php"; } $dbh->prepare(); if ($dbh->execute()) { if (isset($clm)) { $res = $dbh->fetchAssoc(); $final = json_encode($res); } else { $objs = $dbh->fetchAll(); $final = json_encode($objs); } header('Content-Length: ' . strlen($final)); header('Content-Type: application/json'); echo $final; } else { list_error(HTTP_Status::NOT_FOUND); } } catch (\Exception $e) { $message = $e->getPrevious() ? $e->getPrevious()->getMessage() : $e->getMessage(); $code = $e->getPrevious() ? $e->getPrevious()->getCode() : $e->getCode(); $err = "Error Code: " . $code . " <br/>Detailed Info: " . $message; list_error(HTTP_Status::INTERNAL_SERVER_ERROR, $err); }