diff --git a/MysqliDb.php b/MysqliDb.php index 6f1e957e..ab88d03a 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -9,7 +9,7 @@ * @author Alexander V. Butenko * @copyright Copyright (c) 2010-2017 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License - * @link http://github.com/joshcam/PHP-MySQLi-Database-Class + * @link http://github.com/joshcam/PHP-MySQLi-Database-Class * @version 2.9.3 */ @@ -243,7 +243,7 @@ class MysqliDb * @var string the name of a default (main) mysqli connection */ public $defConnectionName = 'default'; - + public $autoReconnect = true; protected $autoReconnectCount = 0; @@ -306,7 +306,7 @@ public function connect($connectionName = 'default') { if(!isset($this->connectionsSettings[$connectionName])) throw new Exception('Connection profile not set'); - + $pro = $this->connectionsSettings[$connectionName]; $params = array_values($pro); $charset = array_pop($params); @@ -551,9 +551,9 @@ private function queryUnprepared($query) * @return string Contains the returned rows from the query. */ public function rawAddPrefix($query){ - $query = str_replace(PHP_EOL, null, $query); + $query = str_replace(PHP_EOL, '', $query); $query = preg_replace('/\s+/', ' ', $query); - preg_match_all("/(from|into|update|join) [\\'\\´]?([a-zA-Z0-9_-]+)[\\'\\´]?/i", $query, $matches); + preg_match_all("/(from|into|update|join|describe) [\\'\\´]?([a-zA-Z0-9_-]+)[\\'\\´]?/i", $query, $matches); list($from_table, $from, $table) = $matches; return str_replace($table[0], self::$prefix.$table[0], $query); @@ -724,10 +724,10 @@ public function withTotalCount() /** * A convenient SELECT * function. * - * @param string $tableName The name of the database table to work with. - * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) - * or only $count - * @param string $columns Desired columns + * @param string $tableName The name of the database table to work with. + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * or only $count + * @param string|array $columns Desired columns * * @return array|MysqliDb Contains the returned rows from the select query. * @throws Exception @@ -766,8 +766,8 @@ public function get($tableName, $numRows = null, $columns = '*') /** * A convenient SELECT * function to get one record. * - * @param string $tableName The name of the database table to work with. - * @param string $columns Desired columns + * @param string $tableName The name of the database table to work with. + * @param string|array $columns Desired columns * * @return array Contains the returned rows from the select query. * @throws Exception @@ -2096,7 +2096,7 @@ public function getLastError() * * @return int */ - public function getLastErrno () { + public function getLastErrno() { return $this->_stmtErrno; } @@ -2464,8 +2464,8 @@ protected function _buildJoin () { else $joinStr = $joinTable; - $this->_query .= " " . $joinType. " JOIN " . $joinStr . - (false !== stripos($joinCondition, 'using') ? " " : " on ") + $this->_query .= " " . $joinType. " JOIN " . $joinStr . + (false !== stripos($joinCondition, 'using') ? " " : " on ") . $joinCondition; // Add join and query diff --git a/dbObject.php b/dbObject.php index 304630a3..70355285 100644 --- a/dbObject.php +++ b/dbObject.php @@ -451,7 +451,7 @@ private function with ($objectName) { if (!property_exists ($this, 'relations') || !isset ($this->relations[$objectName])) die ("No relation with name $objectName found"); - $this->_with[$objectName] = $this->relations[$objectName]; + $this->_with[MysqliDb::$prefix.$objectName] = $this->relations[$objectName]; return $this; } diff --git a/tests/dbObjectTests.php b/tests/dbObjectTests.php index bc29ee6d..e9cd9c42 100644 --- a/tests/dbObjectTests.php +++ b/tests/dbObjectTests.php @@ -41,7 +41,7 @@ Array ('login' => 'user2', 'customerId' => 10, 'firstName' => 'Mike', - 'lastName' => NULL, + 'lastName' => null, 'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")), 'expires' => $db->now('+1Y'), 'loginCount' => $db->inc(2) diff --git a/tests/mysqliDbTests.php b/tests/mysqliDbTests.php index dd74b578..61449ba5 100644 --- a/tests/mysqliDbTests.php +++ b/tests/mysqliDbTests.php @@ -61,7 +61,7 @@ function pretty_print($array) { Array ('login' => 'user2', 'customerId' => 10, 'firstName' => 'Mike', - 'lastName' => NULL, + 'lastName' => null, 'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")), 'createdAt' => $db->now(), 'updatedAt' => $db->now(), @@ -312,7 +312,7 @@ function createTable ($name, $data) { exit; } /// -$db->where ("lastName", NULL, '<=>'); +$db->where ("lastName", null, '<=>'); $r = $db->get("users"); if ($db->count != 1) { echo "Invalid users count on null where()";