@@ -1004,7 +1004,7 @@ public function orHaving($havingProp, $havingValue = null, $operator = null)
10041004 */
10051005 public function join($joinTable, $joinCondition, $joinType = '')
10061006 {
1007- $allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER');
1007+ $allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER', 'NATURAL' );
10081008 $joinType = strtoupper(trim($joinType));
10091009
10101010 if ($joinType && !in_array($joinType, $allowedTypes)) {
@@ -1649,7 +1649,7 @@ protected function _buildJoinOld()
16491649 $joinStr = $joinTable;
16501650 }
16511651
1652- $this->_query .= " " . $joinType . " JOIN " . $joinStr .
1652+ $this->_query .= " " . $joinType . " JOIN " . $joinStr .
16531653 (false !== stripos($joinCondition, 'using') ? " " : " on ")
16541654 . $joinCondition;
16551655 }
@@ -1900,24 +1900,23 @@ protected function _prepareQuery()
19001900 {
19011901 $stmt = $this->mysqli()->prepare($this->_query);
19021902
1903- if ($stmt !== false)
1904- goto release;
1903+ if ($stmt !== false) {
1904+ if ($this->traceEnabled)
1905+ $this->traceStartQ = microtime(true);
1906+ return $stmt;
1907+ }
19051908
19061909 if ($this->mysqli()->errno === 2006 && $this->autoReconnect === true && $this->autoReconnectCount === 0) {
19071910 $this->connect($this->defConnectionName);
19081911 $this->autoReconnectCount++;
19091912 return $this->_prepareQuery();
19101913 }
19111914
1915+ $error = $this->mysqli()->error;
1916+ $query = $this->_query;
1917+ $errno = $this->mysqli()->errno;
19121918 $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);
19211920 }
19221921
19231922 /**
@@ -2356,7 +2355,9 @@ protected function _buildJoin () {
23562355 else
23572356 $joinStr = $joinTable;
23582357
2359- $this->_query .= " " . $joinType. " JOIN " . $joinStr ." on " . $joinCondition;
2358+ $this->_query .= " " . $joinType. " JOIN " . $joinStr .
2359+ (false !== stripos($joinCondition, 'using') ? " " : " on ")
2360+ . $joinCondition;
23602361
23612362 // Add join and query
23622363 if (!empty($this->_joinAnd) && isset($this->_joinAnd[$joinStr])) {
0 commit comments