Skip to content
Pierre Lemée edited this page Jan 1, 2017 · 3 revisions

Mapping your entity classes to your database has never been that easy.

In a nutshell

Initialize a connection, declare the mapper in your entity class and you're ready to operate:

namespace My\Model;

class Book extends Entity
{
    /**
     * @field incremented
     * @primary
     */
    public $id;

    /**
     * @field
     * @type integer
     */
    protected $title;
    /**
     * @field
     * @type string
     */
    protected $author;

    /**
    ... getters, setters and business part
     */
}
<?php index.php

use My\Model\Book;

$book = new Book();
$book->setTitle("The Grapes of Wrath");
$book->setAuthor("John Steinbeck");

$book->save();

$last = Book::findOne("select * from Book order by `date_creation` desc limit 1);

if ($last->getTitle() == $book->getTitle()) {
    echo "It worked!";
}
Clone this wiki locally