Skip to content

merge with master #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Alexander V. Butenko <[email protected]>
* @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
*/

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2096,7 +2096,7 @@ public function getLastError()
*
* @return int
*/
public function getLastErrno () {
public function getLastErrno() {
return $this->_stmtErrno;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/dbObjectTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/mysqliDbTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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()";
Expand Down