Preparation of commit for feature #13134
authorXavier Perseguers <typo3@perseguers.ch>
Tue, 5 Jan 2010 17:05:55 +0000 (17:05 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Tue, 5 Jan 2010 17:05:55 +0000 (17:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@28422 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.ux_t3lib_db.php
typo3/sysext/dbal/class.ux_t3lib_sqlparser.php

index 10bd9d1..ab46aa1 100644 (file)
@@ -1,3 +1,7 @@
+2010-01-05  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Added feature #13134: Support of SQL LOCATE function
+
 2010-01-03  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Added feature #13135: Support for CASE WHEN flow control
index 9ca75ff..a37ec56 100644 (file)
@@ -1145,7 +1145,11 @@ class ux_t3lib_DB extends t3lib_DB {
                        if (is_array($where_clause[$k]['sub'])) {
                                $where_clause[$k]['sub'] = $this->_quoteWhereClause($where_clause[$k]['sub']);
                        } elseif (isset($v['func'])) {
-                               $where_clause[$k]['func']['subquery'] = $this->quoteSELECTsubquery($v['func']['subquery']);
+                               switch ($where_clause[$k]['func']['type']) {
+                                       case 'EXISTS':
+                                               $where_clause[$k]['func']['subquery'] = $this->quoteSELECTsubquery($v['func']['subquery']);
+                                               break;
+                               }
                        } else {
                                if ($where_clause[$k]['table'] != '') {
                                        $where_clause[$k]['table'] = $this->quoteName($where_clause[$k]['table']);
@@ -2601,10 +2605,14 @@ class ux_t3lib_DB extends t3lib_DB {
                                if (is_array($sqlPartArray[$k]['sub'])) {
                                        $this->map_sqlParts($sqlPartArray[$k]['sub'], $defaultTable);   // Call recursively!
                                } elseif (isset($sqlPartArray[$k]['func'])) {
-                                       $subqueryDefaultTable = $sqlPartArray[$k]['func']['subquery']['FROM'][0]['table'];
-                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['SELECT'], $subqueryDefaultTable);
-                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['FROM'], $subqueryDefaultTable);
-                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['WHERE'], $subqueryDefaultTable);
+                                       switch ($sqlPartArray[$k]['func']['type']) {
+                                               case 'EXISTS':
+                                                       $subqueryDefaultTable = $sqlPartArray[$k]['func']['subquery']['FROM'][0]['table'];
+                                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['SELECT'], $subqueryDefaultTable);
+                                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['FROM'], $subqueryDefaultTable);
+                                                       $this->map_sqlParts($sqlPartArray[$k]['func']['subquery']['WHERE'], $subqueryDefaultTable);
+                                                       break;
+                                       }
                                } else {
                                                // For the field, look for table mapping (generic):
                                        $t = $sqlPartArray[$k]['table'] ? $sqlPartArray[$k]['table'] : $defaultTable;
index 5441255..8f59104 100644 (file)
@@ -351,8 +351,8 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
                                                        // Look for sublevel:
                                                if (is_array($v['sub'])) {
                                                        $output .= ' (' . trim($this->compileWhereClause($v['sub'], $functionMapping)) . ')';
-                                               } elseif (isset($v['func'])) {
-                                                       $output .= ' ' . trim($v['modifier']) . ' ' . $v['func']['type'] . ' (' . $this->compileSELECT($v['func']['subquery']) . ')';
+                                               } elseif (isset($v['func']) && $v['func']['type'] === 'EXISTS') {
+                                                       $output .= ' ' . trim($v['modifier']) . ' EXISTS (' . $this->compileSELECT($v['func']['subquery']) . ')';
                                                } else {
 
                                                                // Set field/table with modifying prefix if any: