cvs: pear /LiveUser_Admin/Storage SQL.php

From: Date: Tue, 24 Jan 2006 13:33:39 +0000
Subject: cvs: pear /LiveUser_Admin/Storage SQL.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-37738@lists.php.net to get a copy of this message
lsmith Tue Jan 24 13:33:39 2006 UTC Modified files: /pear/LiveUser_Admin/Storage SQL.php Log: - make sure that tables required as intermediate join steps are listed in the from - add depth parameter to createJoinFilter (may be used to determine shortest join path eventually) - fixed detection if list of tables has been reduced or not - do not push an error on the stack for a possible recursion because it may just be one possible path we are evaluating http://cvs.php.net/viewcvs.cgi/pear/LiveUser_Admin/Storage/SQL.php?r1=1.50&r2=1.51&diff_format=u Index: pear/LiveUser_Admin/Storage/SQL.php diff -u pear/LiveUser_Admin/Storage/SQL.php:1.50 pear/LiveUser_Admin/Storage/SQL.php:1.51 --- pear/LiveUser_Admin/Storage/SQL.php:1.50 Fri Dec 2 12:41:30 2005 +++ pear/LiveUser_Admin/Storage/SQL.php Tue Jan 24 13:33:39 2006 @@ -57,7 +57,7 @@ * @author Bjoern Kraus <krausbn@php.net> * @copyright 2002-2005 Markus Wolff * @license http://www.gnu.org/licenses/lgpl.txt - * @version CVS: $Id: SQL.php,v 1.50 2005/12/02 12:41:30 lsmith Exp $ + * @version CVS: $Id: SQL.php,v 1.51 2006/01/24 13:33:39 lsmith Exp $ * @link http://pear.php.net/LiveUser_Admin */ @@ -432,6 +432,7 @@ return false; } $joinfilters = $result[0]; + $tables = array_merge($tables, array_flip($result[2])); } $tables = array_keys($tables); @@ -700,25 +701,20 @@ * * @access public */ - function createJoinFilter($root_table, $filters, $tables, $selectable_tables, $visited = array()) + function createJoinFilter($root_table, $filters, $tables, $selectable_tables, $visited = array(), $depth = 0) { // table has been joint unset($tables[$root_table]); if (empty($tables)) { - return array($filters, null); + return array($filters, null, $visited); } // check for possible infinite recursion if (in_array($root_table, $visited)) { - $this->_stack->push( - LIVEUSER_ADMIN_ERROR_QUERY_BUILDER, 'exception', - array('reason' => 'infinite recursion detected: ' . $root_table) - ); return false; } $visited[] = $root_table; - $tables_orig = $tables; // find tables that can be join directly with the root table @@ -768,11 +764,12 @@ // all tables have been joined if (empty($tables)) { - return array($filters, null); + return array($filters, null, $visited); } + $tmp_filters = $filters; foreach ($direct_matches as $table) { - $result = $this->createJoinFilter($table, $filters, $tables, $selectable_tables, $visited); + $result = $this->createJoinFilter($table, $tmp_filters, $tables, $selectable_tables, $visited, ($depth+1)); // check if the recursion was able to find a join that would reduce // the number of to be joined tables if (is_array($result)) { @@ -786,7 +783,7 @@ // all tables have been joined if (empty($tables)) { - return array($filters, null); + return array($filters, null, $visited); } foreach ($this->tables[$root_table]['joins'] as $table => $fields) { @@ -836,7 +833,7 @@ $this->prefix.$this->alias[$table].'.'.$fields; } // recurse - $result = $this->createJoinFilter($table, $tmp_filters, $tmp_tables, $selectable_tables, $visited); + $result = $this->createJoinFilter($table, $tmp_filters, $tmp_tables, $selectable_tables, $visited, ($depth+1)); // check if the recursion was able to find a join that would reduce // the number of to be joined tables if (is_array($result)) { @@ -849,12 +846,12 @@ } // return false if list of tables was not reduced using the current root table - if ($tables_orig == $table) { + if ($tables_orig === $tables) { return false; } // return the generated new filters and reduced table list - return array($filters, $tables); + return array($filters, $tables, $visited); } /**

« previous php.pear.cvs (#37738) next »