mimbre/db

A database interface.


License
MIT

Documentation

Database interface.

A database interface. This library is used in combination with other libraries, such as db-mysql.

Install

This library uses the Composer package manager. Simply execute the following command from a terminal:

composer require mimbre\db

Examples

This library uses the Active Record design pattern to insert, update or delete records.

require_once "path/to/vendor/autoload.php";
use mimbre\db\DbActiveRecord;
use mimbre\db\mysql\MySqlConnection;

// connects to a MySQL database
$db = new MySqlConnection("test", "root", "your password");

// inserts a record
$row = new DbActiveRecord($db, "my-table");
$row->title = 'A title';
$row->save();

// updates the previous record
$row = new DbActiveRecord($db, "items", $row->getId());
$row->title = 'Another title';
$row->save();

// deletes the previous record
$row = new DbActiveRecord($db, "items, $row->getId());
$row->delete();

Developer notes

# verifies that the source code conforms the current coding standards
phpcs --standard=phpcs.xml src