Skip to content

fixes #662

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 4 commits into from
Aug 3, 2017
Merged

fixes #662

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
14 changes: 7 additions & 7 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* @author Jeffery Way <[email protected]>
* @author Josh Campbell <[email protected]>
* @author Alexander V. Butenko <[email protected]>
* @copyright Copyright (c) 2010-2016
* @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
* @version 2.8-master
* @version 2.9-master
*/

class MysqliDb
Expand Down Expand Up @@ -582,7 +582,7 @@ public function rawQueryValue($query, $bindParams = null)
* A method to perform select query
*
* @param string $query Contains a user-provided select query.
* @param int|array $numRows Array to define SQL limit in format Array ($count, $offset)
* @param int|array $numRows Array to define SQL limit in format Array ($offset, $count)
*
* @return array Contains the returned rows from the query.
*/
Expand Down Expand Up @@ -654,7 +654,7 @@ 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 ($count, $offset)
* @param int|array $numRows Array to define SQL limit in format Array ($offset, $count)
* or only $count
* @param string $columns Desired columns
*
Expand Down Expand Up @@ -858,7 +858,7 @@ public function update($tableName, $tableData, $numRows = null)
* Delete query. Call the "where" method first.
*
* @param string $tableName The name of the database table to work with.
* @param int|array $numRows Array to define SQL limit in format Array ($count, $offset)
* @param int|array $numRows Array to define SQL limit in format Array ($offset, $count)
* or only $count
*
* @return bool Indicates success. 0 or 1.
Expand Down Expand Up @@ -1474,7 +1474,7 @@ private function _buildInsert($tableName, $insertData, $operation)
* any passed update data, and the desired rows.
* It then builds the SQL query.
*
* @param int|array $numRows Array to define SQL limit in format Array ($count, $offset)
* @param int|array $numRows Array to define SQL limit in format Array ($offset, $count)
* or only $count
* @param array $tableData Should contain an array of data for updating the database.
*
Expand Down Expand Up @@ -1868,7 +1868,7 @@ protected function _buildOrderBy()
/**
* Abstraction method that will build the LIMIT part of the WHERE statement
*
* @param int|array $numRows Array to define SQL limit in format Array ($count, $offset)
* @param int|array $numRows Array to define SQL limit in format Array ($offset, $count)
* or only $count
*
* @return void
Expand Down
4 changes: 2 additions & 2 deletions dbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* @category Database Access
* @package MysqliDb
* @author Alexander V. Butenko <[email protected]>
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015-2017
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @link http://github.com/joshcam/PHP-MySQLi-Database-Class
* @version 2.6-master
* @version 2.9-master
*
* @method int count ()
* @method dbObject ArrayBuilder()
Expand Down
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ If no table prefix were set during object creation its possible to set it later
$db->setPrefix ('my_');
```

If connection to mysql will be dropped Mysqlidb will try to automatically reconnect to the database once.
To disable this behavoir use
```php
$db->autoReconnect = false;
```

If you need to get already created mysqliDb object from another class or function use
```php
function init () {
Expand All @@ -92,6 +98,24 @@ If you need to get already created mysqliDb object from another class or functio
}
```

### Multiple database connection
If you need to connect to multiple databases use following method:
```php
$db->addConnection('slave', Array (
'host' => 'host',
'username' => 'username',
'password' => 'password',
'db'=> 'databaseName',
'port' => 3306,
'prefix' => 'my_',
'charset' => 'utf8')
);
```
To select database use connection() method
```php
$users = $db->connection('slave')->get('users');
```

### Objects mapping
dbObject.php is an object mapping library built on top of mysqliDb to provide model representation functionality.
See <a href='dbObject.md'>dbObject manual for more information</a>
Expand Down