source: Dev/trunk/rdfapi/sparql/SparqlEngineDb/SqlMerger.php @ 12

Last change on this file since 12 was 12, checked in by basvannuland, 14 years ago

Added RAP RDF API
Added RDF reader writer for save and load survey

File size: 1.4 KB
Line 
1<?php
2
3/**
4*   Creates an sql string from an sql array
5*
6*   @author Christian Weiske <cweiske@cweiske.de>
7*   @license http://www.gnu.org/licenses/lgpl.html LGPL
8*
9*   @package sparql
10*/
11class SparqlEngineDb_SqlMerger
12{
13    public static function getSelect(Query $query, $arSqls, $strAdditional = '')
14    {
15        if (count($arSqls) == 1) {
16            return implode('', $arSqls[0]) . $strAdditional;
17        }
18
19        //union
20        $strUnion = 'UNION' .
21            ($query->getResultForm() == 'select distinct' ? '' : ' ALL');
22        $ar = array();
23        foreach ($arSqls as $arSql) {
24            $ar[] = implode('', $arSql) . $strAdditional;
25        }
26        return '(' . implode(') ' . $strUnion . ' (', $ar) . ')';
27    }//public static function getSelect(Query $query, $arSqls, $strAdditional = '')
28
29
30
31    public static function getCount(Query $query, $arSqls, $strAdditional = '')
32    {
33        if (count($arSqls) == 1) {
34            return 'SELECT COUNT(*) as count ' . $arSqls[0]['from'] . $arSqls[0]['where'] . $strAdditional;
35        }
36
37        $ar = array();
38        foreach ($arSqls as $arSql) {
39            $ar[] = implode('', $arSql) . $strAdditional;
40        }
41        return 'SELECT (' . implode(') + (', $ar) . ') as count';
42    }//public static function getCount(Query $query, $arSqls, $strAdditional = '')
43
44}//class SparqlEngineDb_SqlMerger
45
46?>
Note: See TracBrowser for help on using the repository browser.