function ARC_sparql2sql_rewriter::get_select_sql in Taxonomy import/export via XML 5.2
Same name and namespace in other branches
- 5 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::get_select_sql()
- 6.2 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::get_select_sql()
- 6 arc/ARC_sparql2sql_rewriter.php \ARC_sparql2sql_rewriter::get_select_sql()
3 calls to ARC_sparql2sql_rewriter::get_select_sql()
File
- arc/
ARC_sparql2sql_rewriter.php, line 105
Class
Code
function get_select_sql() {
$infos = $this->infos;
if (!$infos["result_vars"]) {
return array(
"error" => 'no result variables specified',
);
}
if (isset($this->infos["patterns"])) {
$this
->parse_patterns();
/* creates where_code, optional_term2alias */
}
if (strpos($this->where_code, "__union_")) {
return $this
->get_union_select_sql();
}
$left_join_code = $this
->get_left_join_code();
/* detects alias_alternatives */
/* select */
$result = "SELECT";
/* distinct */
$result .= isset($infos["distinct"]) && $infos["distinct"] ? " DISTINCT" : "";
/* count rows */
if (isset($infos["count_rows"]) && $infos["count_rows"]) {
$result .= " SQL_CALC_FOUND_ROWS";
}
/* vars */
$result .= $this
->get_result_vars_code();
/* from */
$result .= $this
->get_from_code();
/* left joins */
$result .= strlen($left_join_code) ? "\n /* left-joins */" . $left_join_code : "";
/* id2val joins */
$id2val_join_code = $this
->get_id2val_join_code();
$result .= strlen($id2val_join_code) ? $id2val_join_code : "";
/* where */
$result .= "\nWHERE \n ";
$where_result = "";
/* dataset restrictions */
$dataset_code = $this
->get_dataset_code();
$where_result .= strlen($dataset_code) ? "/* dataset restrictions */\n" . $dataset_code . "\n" : "";
/* graph restrictions */
$graph_code = $this
->get_graph_code();
if (strlen($graph_code)) {
$where_result .= strlen($where_result) ? " /* graph restrictions */\n AND \n " . $graph_code : " /* graph restrictions */\n " . $graph_code;
$where_result .= "\n";
}
/* where_code */
if (strlen($this->where_code)) {
$where_result .= strlen($where_result) ? " /* triple patterns and filters */\n AND \n " : " /* triple patterns and filters */\n ";
$where_result .= trim($this->where_code);
}
/* equi-joins */
if ($equi_join_code = $this
->get_equi_join_code()) {
$where_result .= strlen($where_result) ? "\n /* equi-joins */\n AND " . $equi_join_code : "\n /* equi-joins */\n " . $equi_join_code;
}
$result .= strlen($where_result) ? $where_result : "1";
/* order by */
$result .= $this
->get_order_by_code();
/* limit/offset */
$result .= $this
->get_limit_offset_code();
return $result;
}