mtoolkit/mtoolkit-model

The model module of MToolkit framework

0.0.3 2017-11-07 15:41 UTC

This package is not auto-updated.

Last update: 2024-12-20 15:58:33 UTC


README

The model module of MToolkit framework.

Summary

#Intro The module provides the classes to represent x-dimensional models, as list or table. There are a submodule about the sql models: to run a query, to retrieve a resultset, etc...

MDbConnection

It provides a simple singleton way to store the connection to the database. Usages:

// Add a new connection string
MDbConnection::addDbConnection( new \PDO( 'mysql:host=127.0.0.1;dbname=test_db', 'root', 'password' ) );

// Retrieve the database connection
$connection = MDbConnection::getDbConnection();

MPDOQuery and MPDOResult

Usages:

$query = "SELECT item_01 FROM table_01";
$connection = MDbConnection::getDbConnection();
$sql = new MPDOQuery( $query, $connection );
$sql->bindValue( $key );
$sql->exec();
$result = $sql->getResult();