Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fixed limit variable ordering in the comments

* Expand readme on autoreconnect and multipe connections usage

* update release numbers

* update copyright years

* Bug ThingEngineer#623:  Mistake in Regexp

* Fix for ThingEngineer#554 Fixing Join usage with 'USING' instead of 'ON'

* Fix empty exception message
  • Loading branch information
avbdr authored and ricwein committed Aug 29, 2017
1 parent f948779 commit f1fc9ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ public function orHaving($havingProp, $havingValue = null, $operator = null)
*/
public function join($joinTable, $joinCondition, $joinType = '')
{
$allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER');
$allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER', 'NATURAL');
$joinType = strtoupper(trim($joinType));

if ($joinType && !in_array($joinType, $allowedTypes)) {
Expand Down Expand Up @@ -1649,7 +1649,7 @@ protected function _buildJoinOld()
$joinStr = $joinTable;
}

$this->_query .= " " . $joinType . " JOIN " . $joinStr .
$this->_query .= " " . $joinType . " JOIN " . $joinStr .
(false !== stripos($joinCondition, 'using') ? " " : " on ")
. $joinCondition;
}
Expand Down Expand Up @@ -1900,24 +1900,23 @@ protected function _prepareQuery()
{
$stmt = $this->mysqli()->prepare($this->_query);

if ($stmt !== false)
goto release;
if ($stmt !== false) {
if ($this->traceEnabled)
$this->traceStartQ = microtime(true);
return $stmt;
}

if ($this->mysqli()->errno === 2006 && $this->autoReconnect === true && $this->autoReconnectCount === 0) {
$this->connect($this->defConnectionName);
$this->autoReconnectCount++;
return $this->_prepareQuery();
}

$error = $this->mysqli()->error;
$query = $this->_query;
$errno = $this->mysqli()->errno;
$this->reset();
throw new Exception(sprintf('%s query: %s', $this->mysqli()->error, $this->_query), $this->mysqli()->errno);

release:
if ($this->traceEnabled) {
$this->traceStartQ = microtime(true);
}

return $stmt;
throw new Exception(sprintf('%s query: %s', error, query), errno);
}

/**
Expand Down Expand Up @@ -2356,7 +2355,9 @@ protected function _buildJoin () {
else
$joinStr = $joinTable;

$this->_query .= " " . $joinType. " JOIN " . $joinStr ." on " . $joinCondition;
$this->_query .= " " . $joinType. " JOIN " . $joinStr .
(false !== stripos($joinCondition, 'using') ? " " : " on ")
. $joinCondition;

// Add join and query
if (!empty($this->_joinAnd) && isset($this->_joinAnd[$joinStr])) {
Expand Down
2 changes: 1 addition & 1 deletion dbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ private function validate ($data) {
$regexp = "/^[0-9\.]*$/";
break;
case "bool":
$regexp = '/^[yes|no|0|1|true|false]$/i';
$regexp = '/^(yes|no|0|1|true|false)$/i';
break;
case "datetime":
$regexp = "/^[0-9a-zA-Z -:]*$/";
Expand Down

0 comments on commit f1fc9ff

Please sign in to comment.