PHP code example of divengine / orm

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




ivengine\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
{
    public $id = self::AUTOMATIC;
    public $name;
}

class PersonCollection extends PersonMap
{
    protected $__map_type = self::TABLE;
}

$pdo = orm::buildPDO([
    'type' => 'pgsql',
    'host' => 'localhost',
    'port' => 5432,
    'name' => 'mydb',
    'user' => 'me',
    'pass' => 'secret'
], true);

$person = new Person(['name' => 'Peter']);
$person->insert();

$list = new PersonCollection();
$first = $list->getFirstItem('id = ?', [100]);