Fork me on GitHub

About POMM

What is it ?

Pomm is a lightweight, fast, efficient and powerful PHP Object Model 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 features. It works with PHP 5.3 and Postgresql 8.4 and above.

Why is Pomm only working with Postgresql ?

Because Pg does offer a lot of nice features you cannot take advantage of with classical ORMs as they implement a database abstraction layer. The idea was to make developers able to benefit from the power of Postgres'SQL with the ease of object oriented PHP.

Some people asked me if Pomm could work with Mysql. We have tried but it cannot because Pomm uses the RETURNING statement internally which MySQL does not implement and MySql lacks so many data types, there is no real interest having a converter system.

What does Pomm propose ?

  • Database introspection and model generation
  • Lazy hydration and on the fly type conversion
  • SQL, 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, Pomm's tools 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 different PHP namespaces, there will not be naming collision anymore !

Lazy hydration and on the fly type conversion

Queries return Collections which are iterators on results. 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 period, HStore and ltree extensions.

SQL, finders and pagers

Of course 80% of the queries of a web applications are like «SELECT ... FROM ... 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. For the more complicated queries, SQL is the way to go. You can use all the awesome operators, full text search, window functions, recursive queries, (insert 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.

Who is behind Pomm

My name is Grégoire HUBERT and I have started working on Pomm 2 years ago which was named PgLook at the time (you can still use it for your symfony 1.x projects although it is not maintained anymore). Pomm has evolved based on my projects and professional needs. It is released under the MIT/X11 licence so feel free to use, distribute or modify it. You can send me an email at hubert dot greg at gmail dot com.