Source for file SqlMerger.php

Documentation is available at SqlMerger.php

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

Documentation generated on Fri, 1 Jun 2007 16:52:25 +0200 by phpDocumentor 1.3.2