@@ -1004,7 +1004,7 @@ public function orHaving($havingProp, $havingValue = null, $operator = null)
1004
1004
*/
1005
1005
public function join ($ joinTable , $ joinCondition , $ joinType = '' )
1006
1006
{
1007
- $ allowedTypes = array ('LEFT ' , 'RIGHT ' , 'OUTER ' , 'INNER ' , 'LEFT OUTER ' , 'RIGHT OUTER ' );
1007
+ $ allowedTypes = array ('LEFT ' , 'RIGHT ' , 'OUTER ' , 'INNER ' , 'LEFT OUTER ' , 'RIGHT OUTER ' , ' NATURAL ' );
1008
1008
$ joinType = strtoupper (trim ($ joinType ));
1009
1009
1010
1010
if ($ joinType && !in_array ($ joinType , $ allowedTypes )) {
@@ -1649,7 +1649,7 @@ protected function _buildJoinOld()
1649
1649
$ joinStr = $ joinTable ;
1650
1650
}
1651
1651
1652
- $ this ->_query .= " " . $ joinType . " JOIN " . $ joinStr .
1652
+ $ this ->_query .= " " . $ joinType . " JOIN " . $ joinStr .
1653
1653
(false !== stripos ($ joinCondition , 'using ' ) ? " " : " on " )
1654
1654
. $ joinCondition ;
1655
1655
}
@@ -1900,24 +1900,23 @@ protected function _prepareQuery()
1900
1900
{
1901
1901
$ stmt = $ this ->mysqli ()->prepare ($ this ->_query );
1902
1902
1903
- if ($ stmt !== false )
1904
- goto release;
1903
+ if ($ stmt !== false ) {
1904
+ if ($ this ->traceEnabled )
1905
+ $ this ->traceStartQ = microtime (true );
1906
+ return $ stmt ;
1907
+ }
1905
1908
1906
1909
if ($ this ->mysqli ()->errno === 2006 && $ this ->autoReconnect === true && $ this ->autoReconnectCount === 0 ) {
1907
1910
$ this ->connect ($ this ->defConnectionName );
1908
1911
$ this ->autoReconnectCount ++;
1909
1912
return $ this ->_prepareQuery ();
1910
1913
}
1911
1914
1915
+ $ error = $ this ->mysqli ()->error ;
1916
+ $ query = $ this ->_query ;
1917
+ $ errno = $ this ->mysqli ()->errno ;
1912
1918
$ this ->reset ();
1913
- throw new Exception (sprintf ('%s query: %s ' , $ this ->mysqli ()->error , $ this ->_query ), $ this ->mysqli ()->errno );
1914
-
1915
- release:
1916
- if ($ this ->traceEnabled ) {
1917
- $ this ->traceStartQ = microtime (true );
1918
- }
1919
-
1920
- return $ stmt ;
1919
+ throw new Exception (sprintf ('%s query: %s ' , error, query), errno);
1921
1920
}
1922
1921
1923
1922
/**
@@ -2356,7 +2355,9 @@ protected function _buildJoin () {
2356
2355
else
2357
2356
$ joinStr = $ joinTable ;
2358
2357
2359
- $ this ->_query .= " " . $ joinType . " JOIN " . $ joinStr ." on " . $ joinCondition ;
2358
+ $ this ->_query .= " " . $ joinType . " JOIN " . $ joinStr .
2359
+ (false !== stripos ($ joinCondition , 'using ' ) ? " " : " on " )
2360
+ . $ joinCondition ;
2360
2361
2361
2362
// Add join and query
2362
2363
if (!empty ($ this ->_joinAnd ) && isset ($ this ->_joinAnd [$ joinStr ])) {
0 commit comments