brunnofoggia / doctrine-dashes
This is an additional active record pack for DBAL Integration. It will provide all is needed to connect with a database, read and persist relational data quick and easy.
1.12.0
2019-11-25 17:40 UTC
Requires
- php: >=5.4.0
- brunnofoggia/darktrait: 1.*
- brunnofoggia/hbasis: 1.*
- doctrine/dbal: ^2.5
README
This is an additional active record pack for DBAL Integration. It will provide all is needed to connect with a database, read and persist relational data quick and easy
Version notice
This works for DBAL ^2.5
What this plugin provides?
Features for Model
- Persist methods - save, update, create, delete, deleteAll
- Retrieve methods - get, find, exists
- Persist related data methods - saveBelongsTo, saveHasMany, saveHasAndBelongsToMany
- Retrieve related data methods - getRelated, getBelongsTo, getHasMany, getHasAndBelongsToMany
- Properties available for customization: table, primaryKey, foreignKeys[], fieldsFormat[], recursive
Installation
You should install this with composer. Read the VCS repo docs. A initial composer.json would looks like:
{
"require": {
"doctrine/dbal": "^2.5",
"brunnofoggia/doctrine-dashes": "@dev"
}
}
Usage
Import it into classes that will use it
class Sample_model {
use \doctrine\Dashes\Model; protected $table = 'sample';
}
Get an instance of the model
2.1. Setting connection config before
\Sample_model::setConnConfig('default', [ 'host' => 'localhost', 'user' => 'root', 'pass' => '123', 'dbname' => 'test' ]); $test = new Sample_model;
2.2. Sending connection config
$test = new Sample_model([ 'host' => 'localhost', 'user' => 'root', 'pass' => '123', 'dbname' => 'test' ]);
try to read a record
$pk = 1; $test->get($pk);