1. Go to this page and download the library: Download divengine/orm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
divengine / orm example snippets
use divengine\orm;
class PublicMap extends orm
{
protected $__map_type = self::SCHEMA;
protected $__map_schema = 'public';
protected $__map_identity = 'id = :id';
}
class PersonMap extends PublicMap
{
protected $__map_type = self::RECORD;
protected $__map_name = 'person';
protected $__map_class = Person::class;
}
class Person extends PersonMap {
private $id = self::AUTOMATIC;
private $name;
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
}
}
class PersonCollection extends PersonMap {
protected $__map_type = self::TABLE;
}
use divengine\orm;
$pdo = new PDO(); // or use orm::buildPDO();
orm::connectGlobal($pdo); // or pass true to second param of orm::buildPDO()
$person = new Person(['name' => 'Peter']);
// $person::connect($pdo);
$person->insert();
$list = new PersonCollection();
$list->addItem($person);
$entity = $list->getFirstItem('id = ?', [100]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.