Exemplo n.º 1
0
        $table = ormlib::get_from_instance(new metadata_table(), array("id"), array($field->metadata_table_id));
        $query_elements = query::get_query_elements($table->metadata_id, $element_fields);
        for ($j = 0; $j < count($field_list_key); $j++) {
            $metadata_field = report_wrapper::get_from_instance(new metadata_field(), array("id"), array($field_list_key[$j]));
            $metadata_table = report_wrapper::get_from_instance(new metadata_table(), array("id"), array($metadata_field->metadata_table_id));
            if ($metadata_table->id * 1 !== $table->metadata_id) {
                $query_elements1 = query::get_query_elements($metadata_table->metadata_id);
                $query_elements["from"] = array_merge($query_elements["from"], $query_elements1["from"]);
                $query_elements["relations"] = array_merge($query_elements["relations"], $query_elements1["relations"]);
            }
        }
        //Get Datastructur for Query for metadata
        $query_fields = implode($query_elements["fields"], ",");
        $query_from = implode($query_elements["from"], ",");
        $query_elements["relations"] = array_merge($query_elements["relations"], query::get_field_relations($field_list_key, $field_list_value));
        $query_elements["relations"] = array_merge($query_elements["relations"], query::get_meta_relations($field_list_key, $table->metadata_id));
        $query_relation = implode($query_elements["relations"], " AND ");
        $query = "SELECT {$query_fields} from {$query_from}  WHERE {$query_relation}";
        $result = $dbconnection->do_query_data_response($query);
        $list = array();
        while ($myrow = mysql_fetch_array($result)) {
            $arr = array();
            foreach ($myrow as $key => $value) {
                $arr[$key] = $value;
            }
            $list[] = $arr;
        }
        $values[$rw->report_element_list[$i]->id] = $list;
    }
    echo json_encode($values);
}