Creating a model layer with PDO

Im currently developing an MVC application platform, and I came up with some tips on how I should build my model layers.

The model is built so that each model is mapped to a table in the database for these applications, so a typical application will have

  • Configuration
  • Themes
  • Forums

and each will appear where the PHP file is specified, such as app/models/configuration.php

Now the problem is creating the parent class of the database to process certain table data, for example:

class PDOModel
{
    public function __construct()
    {
        $this->__Communicator = Registry::getPDOInstance();
    }

    public function getSingle($id)
    {
         return /*Row*/;
    }

    /*Etc*/
}

And something like this for

class Model_Topic extends PDOModel
{
    protected $__id_column = 'id';
}

and then in my controller I can use like this:

$Topic = $this->model->topic->get(22);

But I would also like to take into account also the automatic join of tables, are there any simple lightweight libraries that have been tested and meet my requirements.

.

+3
2
+5

, , - Zend_Db, Table Row PDO. , .

, , "", ORM. , , ORM. Propel >= 1.5, Doctrine 1.2 Doctrine2.

0

All Articles