Skip to content

Commit 39cbf5d

Browse files
author
meritel
committed
new feature: reset the database connections
1 parent 2444f2f commit 39cbf5d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Installation via composer:
3131
$result = $db->get_row('SELECT * FROM user WHERE id=?', [ 1 ]); // Returns one row
3232
$result = $db->get_column('SELECT id FROM user', []); // Returns 1 column
3333
$result = $db->get_one('SELECT username FROM user WHERE id=?', [ 1 ]); // Returns 1 field
34+
$columns = $db->get_columns('user'); // Gets the columns for table 'user'
3435

3536
$data = [
3637
'username' => 'testuser',
@@ -42,4 +43,7 @@ Installation via composer:
4243
$where = 'id=' . $db->quote(1);
4344
$result = $db->update('user', $data, $where); // Updates a row
4445

46+
// To remove all existing connections
47+
Database::Reset();
48+
4549
more to come...

lib/Skeleton/Database/Database.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,16 @@ public static function Get($dsn = null, $use_as_default = false) {
6666
}
6767
return self::$proxy[$dsn];
6868
}
69+
70+
/**
71+
* Reset
72+
* Resets all existing connections
73+
*
74+
* @access public
75+
*/
76+
public static function Reset() {
77+
self::$proxy = [];
78+
self::$default_dsn = null;
79+
self::$pids = [];
80+
}
6981
}

0 commit comments

Comments
 (0)