Skip to content

Commit

Permalink
new feature: reset the database connections
Browse files Browse the repository at this point in the history
  • Loading branch information
meritel committed Feb 28, 2017
1 parent 2444f2f commit 39cbf5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Installation via composer:
$result = $db->get_row('SELECT * FROM user WHERE id=?', [ 1 ]); // Returns one row
$result = $db->get_column('SELECT id FROM user', []); // Returns 1 column
$result = $db->get_one('SELECT username FROM user WHERE id=?', [ 1 ]); // Returns 1 field
$columns = $db->get_columns('user'); // Gets the columns for table 'user'

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

// To remove all existing connections
Database::Reset();

more to come...
12 changes: 12 additions & 0 deletions lib/Skeleton/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ public static function Get($dsn = null, $use_as_default = false) {
}
return self::$proxy[$dsn];
}

/**
* Reset
* Resets all existing connections
*
* @access public
*/
public static function Reset() {
self::$proxy = [];
self::$default_dsn = null;
self::$pids = [];
}
}

0 comments on commit 39cbf5d

Please sign in to comment.