Skip to content
/ Pomm Public
forked from chanmix51/Pomm

PHP Object Model Manager for Postgresql

Notifications You must be signed in to change notification settings

oytuntez/Pomm

 
 

Repository files navigation

POMM: The PHP Object Model Manager for Postgresql

https://secure.travis-ci.org/chanmix51/Pomm.png?branch=master

What is Pomm ?

Pomm is a lightweight, fast, efficient and powerful PHP object manager for the Postgresql relational database. Pomm is not an ORM, it is more like an object hydrator above PDO implementing the identity map design pattern and proposing convenient functionalities. Dropping the abstraction layer makes programmers able to take advantage of most of Postgresql's awesome features.

Pomm works with PHP 5.3 and Postgresql 8.4 and above.

You can reach

What does Pomm propose ?

  • Database introspection and model generation
  • Lazy hydration and on the fly type conversion
  • SQL queries, virtual fields, finders and pagers
  • Collection, filters and query filters
  • A Where clause builder
  • Security and debuging tools

Database introspection and model generation

Once you have designed your database using your favorite tool, Pomm can generate PHP model classes for you by inspecting tables and views. It checks the schema where your database objects are stored so generated classes use according PHP namespaces, there will not be naming collision anymore ! Of Course, Postgresql's table inheritance is supported.

Lazy hydration and on the fly type conversion

Queries return collections which are scrollable iterators on results. Fetched objects are hydrated on demand for minimal memory consumption and data are converted from/to Postgresql. Boolean in Pg are boolean in PHP, arrays in Pg are arrays in PHP, geometric types are converted into geometric PHP objects. Of course this is extendible and custom database types can be converted into custom PHP classes. Almost all standard and geometric types are supported plus range, HStore and ltree extensions.

SQL queries, virtual fields, finders and pagers

Of course 80% of the queries of a web applications are like SELECT * FROM my_table WHERE ... So there is a method for that. You can configure what you do want in the select fields in case you would like to add your classes extra properties. You can even use them with the converter system with extra fields adding them as virtual fields. For the more complicated queries, SQL is the way to go. You can use all the awesome operators, full text search, window functions, CTEs and recursive queries, (add your preferred feature here).

Collection filters and query filters

When retrieving data from the database trough a Collection object, it is possible to register PHP anonymous functions as filters before objects are hydrated. This is very powerful as you can create foreign objects or code you own filters.

Queries are also made in a Filter Chain design pattern. You can add your own filters to place code before and/or after each query.

A Where clause builder

Sometimes, you want to create a WHERE clause dynamically. Pomm proposes a Where class to let you AND and/or OR your conditions passing the values as argument each time for escaping. There is even a WhereIn method with an array of values as parameter.

Security and debuging tools

All queries are prepared, the values you give as argument are automatically escaped by the server. Furthermore, the converter system ensures there is no type enforcing.

To be sure everything is fine, you can register the LoggerFilter to your connection so you will keep track of every query with statistics like the time it took, the number of results returned etc.

How to install Pomm ?

The easy way: composer

Using composer installer and autoloader is probably the easiest way to install Pomm and get it running. What you need is just a composer.json file in the root directory of your project:

{
"require": {
    "pomm/pomm": "master-dev"
  }
}

Invoking composer.phar will automagically download Pomm, install it in a vendor directory and set up the according autoloader. Check out this tutorial for step by step explanation.

Using Pomm with a PHP framework

How to contribute to Pomm ?

That's very easy with github:

  • Send feedback to @PommProject on twitter or by mail at <hubert DOT greg AT gmail DOT com>
  • Report bugs (very appreciated)
  • Fork and PR (very very appreciated)
  • Send vacuum tubes to the author (actual preferred are russians 6Φ12Π, 6Ж43Π, 6Ж38Π, 6C19Π)

About

PHP Object Model Manager for Postgresql

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%