Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
+27
-11
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Database SELECT Statement
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 28 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Db;
|
||||
@@ -118,11 +117,11 @@ class _Select implements \Iterator, \Countable
|
||||
{
|
||||
case 'INNER':
|
||||
case 'CROSS':
|
||||
$query .= 'INNER JOIN ';
|
||||
$query .= ' INNER JOIN ';
|
||||
break;
|
||||
|
||||
case 'STRAIGHT_JOIN':
|
||||
$query .= 'STRAIGHT_JOIN';
|
||||
$query .= ' STRAIGHT_JOIN';
|
||||
if ( $using )
|
||||
{
|
||||
throw new \InvalidArgumentException; // USING cannot be used with STRAIGHT_JOIN
|
||||
@@ -131,7 +130,7 @@ class _Select implements \Iterator, \Countable
|
||||
|
||||
case 'LEFT':
|
||||
case 'RIGHT':
|
||||
$query .= $type . ' JOIN';
|
||||
$query .= ' ' . $type . ' JOIN';
|
||||
$joinConditionIsOptional = FALSE;
|
||||
break;
|
||||
case 'JOIN':
|
||||
@@ -197,7 +196,17 @@ class _Select implements \Iterator, \Countable
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
|
||||
/* If we are joining on a sub-query already, remove it temporarily to ensure our regex below works correctly */
|
||||
$subqueries = array();
|
||||
|
||||
while( preg_match( "/JOIN\( SELECT(.+?)\) AS .+? ON .+?/", $this->query, $matches ) )
|
||||
{
|
||||
$key = md5( $matches[0] );
|
||||
$subqueries[ $key ] = $matches[0];
|
||||
$this->query = str_replace( $matches[0], $key, $this->query );
|
||||
}
|
||||
|
||||
if ( mb_strstr( $this->query, 'UNION' ) )
|
||||
{
|
||||
$this->query = str_replace( 'derivedTable', "derivedTable {$query}", $this->query );
|
||||
@@ -206,7 +215,13 @@ class _Select implements \Iterator, \Countable
|
||||
{
|
||||
$this->query = preg_replace( '/(WHERE|GROUP BY|HAVING|LIMIT|ORDER BY|$)/', $query . ' $1', $this->query, 1 );
|
||||
}
|
||||
|
||||
|
||||
/* Now put our subquery joins back in */
|
||||
foreach( $subqueries as $k => $v )
|
||||
{
|
||||
$this->query = str_replace( $k, $v, $this->query );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -362,7 +377,7 @@ class _Select implements \Iterator, \Countable
|
||||
|
||||
if ( !$meta )
|
||||
{
|
||||
throw new \IPS\Db\Exception( "Something went wrong. Please try again.", $this->stmt->errno, NULL, $this->query, array_merge( $this->joinBinds, $this->binds ) );
|
||||
throw new \IPS\Db\Exception( "No result metadata - possible table crash", -1, NULL, $this->query, array_merge( $this->joinBinds, $this->binds ) );
|
||||
}
|
||||
|
||||
while ( $field = $meta->fetch_field() )
|
||||
@@ -556,6 +571,7 @@ class _Select implements \Iterator, \Countable
|
||||
if ( !$this->stmt )
|
||||
{
|
||||
$this->runQuery();
|
||||
$this->rewound = FALSE;
|
||||
}
|
||||
|
||||
if ( $allRows )
|
||||
|
||||
Reference in new issue
Block a user