PHP Object Model Manager for Postgresql

Related tags

Database Pomm
Overview

POMM: The PHP Object Model Manager for Postgresql

https://secure.travis-ci.org/chanmix51/Pomm.png?branch=master https://scrutinizer-ci.com/g/chanmix51/Pomm/badges/quality-score.png?s=5766ac7091629c3af205bbcca8623bd2e8cfe85e https://poser.pugx.org/Pomm/Pomm/version.png https://poser.pugx.org/Pomm/Pomm/d/total.png

Note

This is the 1,x version of Pomm. This package is not maintained anymore, the stable Pomm 2.0 is the new generation of Pomm Model Manager.

What is Pomm ?

Pomm is an open source Postgresql access framework for PHP. It is not an ORM, it is an Object Model Manager. Pomm offers an alternative approach than ORM to using database in object oriented web developments. Read more here.

Pomm devel works with PHP 5.4 and Postgresql 9.0 and above.

You can reach

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.

Using Pomm with a PHP framework

With Silex, it is possible to bootstrap a kitchen sink using this gist <https://gist.github.com/chanmix51/3402026>, in an empty directory just issue the command:

wget -O - 'https://gist.github.com/chanmix51/3402026/raw/3cf2125316687be6d3ab076e66f291b68b422ce7/create-pomm-silex.sh' | bash

And follow the instructions.

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Π)

Running tests

psql -c 'CREATE DATABASE pomm_test' -U postgres -h 127.0.0.1
psql -c 'CREATE EXTENSION hstore' -U postgres -h 127.0.0.1 pomm_test
psql -c 'CREATE EXTENSION ltree' -U postgres -h 127.0.0.1 pomm_test

phpunit --configuration tests/phpunit.travis.xml
Comments
  • Split the BaseObjectMap

    Split the BaseObjectMap

    This class should be split in order to be able to create Map instances on non table objects (rows ... like a SELECT by example or a VIEW). This would mean separation on everything related to tables (UPDATE, INSERT, DELETE) and the way fields are retreived.

    feature request refactoring 
    opened by chanmix51 11
  • Service layer

    Service layer

    Hi,

    I have added a branch with a new feature: a Pomm\Connection\Service layer. This class has the ability to perform transactions in place of Connection in the previous versions. Because complex transaction involving lot of tables should not lie in the controllers and cannot be in a Map class either there was no real place to do such tasks with Pomm.

    This is particularly useful when doing data consolidation, let's take an example. Imagine probes sending data. Once in while, those data are aggregated in other tables. Service class could be like the following:

    <?php
    
    use Pomm\Connection\Service;
    
    class MyService extends Service
    {
        protected function getMapFor($class)
        {
            return $this->connection->getMapFor(sprintf("\My\App\%s", $class));
        }
        public function computeData($to_timestamp)
        {
            try
            {
                $this->begin();
                $this->getMapFor('UsefulData')
                    ->fetchFrom($to_timestamp);
                $this->getMapFor('ProbeData')
                    ->deleteFrom($to_timestamp);
                $this->commit();
            }
            catch(ConnectionException $e)
            {
                $this->rollback();
    
                throw $e;
            }
    
            return $this;
        }
    }
    

    Since transactions are not widely available from Connection anymore, I had to refactor the tests to make them pass. But it made them clearer and more understandable (still some work to do here btw) but this also means it breaks backward compatibilty and it makes difficult to migrate big apps from 1.2 to 1.3.

    In order not to do something harmful, I have pushed this feature on a servicelayer branch. Would some of you test it and post some feedback ? Thx

    BC break refactoring discussion 
    opened by chanmix51 8
  • Don't require Composer to install Pomm

    Don't require Composer to install Pomm

    I have tried to load Pomm but it gave me error. http://stackoverflow.com/q/20481613/233286

    Is it possible to provide it without need for Composer? (with its own autoloader)

    For portability reasons and there are people who cannot install Composer.

    feature request 
    opened by ilhanyumer 8
  • Properly handle uninitialized connection

    Properly handle uninitialized connection

    The initial problem, when I create a second connections:

    Warning: pg_close() expects parameter 1 to be resource, null given in Pomm/Connection/Connection.php line 147
    

    This probably silenced the real problem, but I don’t understand what happens.

    opened by sanpii 7
  • Json converter to output/input PHP arrays

    Json converter to output/input PHP arrays

    I was not sure to have to touch stored json as it could be decoded in an entity getter but it appears Json API just export entities as array and any json content is then escaped by a json_encode php call.

    Do you think the json converter should use json_decode and json_encode or just treat them as text and let the developers do what they want with it ?

    opened by chanmix51 6
  • Collections not working with Twig?

    Collections not working with Twig?

    If I have a collection from a query, something like

    $positions = $this->get('pomm')
        ->getDatabase()
        ->createConnection()
        ->getMapFor('Survos\GeoBundle\Pomm\Position')
        ->findWhere('true', array(), 'LIMIT 3');
    

    and I pass it to a Twig template and try this

    {% for i, d in dateCounts %}
        {{ dump(i, d) }}
    {% endfor %}
    

    then instead of entities I get boolean false:

    int 0
    
    boolean false
    
    int 1
    
    boolean false
    
    int 2
    
    boolean false
    

    I don't see what I might be doing wrong.

    bug 
    opened by kcivey 6
  • ScanSchemaTool and custom path/namespace

    ScanSchemaTool and custom path/namespace

    ScanSchemaTool save files in $prefix_dir/Dbname/Schema/ with namespace $namespace\Dbname\Schema

    But i my environment, dev and prod have different Dbname, so i have to re-generate models and do a replacement of \Models\DevDbName\DevSchema by \Models\ProdDbname\ProdSchema

    But i think it will be more powerfull to set prefix using :

    array(
    "prefix_dir" => "Foo/Bar/%dbname%/Baz/%schema%",
    "namespace" => 'Models\\Foo\\Bar\\%dbname%\\Baz\\%schema%',
    );
    

    for my environment i use :

    array(
    "prefix_dir" => "ProjectName/Models/%schema%",
    "namespace" => 'ProcjectName\\Models\\%schema%',
    );
    
    feature request 
    opened by pgoergler 6
  • Using __sleep and __desctruct in collection

    Using __sleep and __desctruct in collection

    Hi,

    I know that you can use a custom collection class with your Pomm project, but i suggest to add theses __sleep and __descruct method in the Collection class in order to make them serializable.

    opened by npotier 5
  • BaseObjectMap related to Database Connection

    BaseObjectMap related to Database Connection

    In my environment i have many databases connections, one model is related to one databases connections. So in my application i have to do :

    $entity1 = $database1
      ->createConnection()
      ->getMapFor('Database1\Schema\MyFirstEntity')
      ->createObject();
    $entity2 = $database2
      ->createConnection()
      ->getMapFor('Database2\Schema\MySecondEntity')
      ->createObject();
    

    So we have to remember on which connection the entity is related to. Does the ObjectMap know his connection ?

    Is there something like ?

    <?php
    $map = new \Database\Schema\MyFirstEntityMap();
    $e = $map->createObject();
    [...]
    $map->save($e);
    
    $cnx = $map->getDefaultDatabase();
    $map->setDefaultDatabase($cnx);
    
    // also
    
    $map2 = $database2
      ->createConnection()
      ->getMapFor('Database2\Schema\MySecondEntity');
    $e2 = $map->createObject();
    $map2->save($e2);
    
    opened by pgoergler 5
  • fluent interface implementation

    fluent interface implementation

    I suggest to implement whenever its possible a fluent interface to most Pomm methods - it's cheap, and can be very useful :)

    For instance, while I'm writing a UT with PHPUnit, I have to feed a test with a DataProvider. I'd like to keep it compact, and thus would like to write something like that:

    return
                    [
                        [(new Clients())->hydrate(['activated_on' => new \DateTime('2010-2-5')]), true]
                    ];
    

    Unfortunately, hydrate() method returns void, so I have to break my code in multiple parts, doing that:

    $client = new Clients();
                $client->hydrate(['activated_on' => new \DateTime('2010-2-5')]);
                $dataSets[] = [$client, true]; 
    
                return $dataSets;
    

    If hydrate() would return $this; the first sample would be working fine and save me loads of lines of code :)

    refactoring 
    opened by gauthier 4
  • PostGIS Data Type handling

    PostGIS Data Type handling

    Hi, is there a way to wrap specific table fields with functions when reading and writing the database?

    Specifically, we have spacial database using PostGIS extensions where the "geometry" type is encoded internally. PostGIS provides functions to extract them as geoJSON or other formats. To use these you perform a "select ST_AsGeoJSON(field_name)..." statement.

    I see you have converters that can process data retrieved from the database but at that point it's too late. We need the above sql run when executing ->findWhere(), ->findAll(), etc calls on the Entities so that the data returned to PHP from postgres is JSON output from the ST_AsGeoJSON call in the select statement.

    Any thoughts on how to accomplish this in POMM?

    opened by ericrisler 4
Owner
Grégoire HUBERT
Grégoire HUBERT
A simple PHP library to transfer data from a source (object or array) to an object.

SimplexMapper A simple PHP library to transfer data from a source (object or array) to an object. $dbData = [ 'username' => 'pfazzi', 'emailAd

Patrick Luca Fazzi 4 Sep 22, 2022
Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.

Aura.SqlQuery Provides query builders for MySQL, Postgres, SQLite, and Microsoft SQL Server. These builders are independent of any particular database

Aura for PHP 424 Dec 12, 2022
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL extension

Swoole Coroutine PostgreSQL Doctrine DBAL Driver A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL. Getting started Install

Leo Cavalcante 19 Nov 25, 2022
Support for many missing PostgreSQL specific features

Laravel supports many different databases and therefore has to limit itself to the lowest common denominator of all databases. PostgreSQL, however, of

Tobias Petry 359 Jan 3, 2023
Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster.

Laravel Thermite Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster. ?? Supporting If you are usin

Renoki Co. 9 Nov 15, 2022
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
PostgreSQL enhancements for Doctrine

PostgreSQL enhancements for Doctrine. Provides support for advanced data types (json, jssnb, arrays), text search, array operators and jsonb specific functions.

Martin Georgiev 258 Dec 31, 2022
Orm is a simple database abstraction layer that supports postgresql.

Orm What is it Orm is a simple database abstraction layer that supports postgresql. Welcome to join us or star us for encouragement. Requires php 8.1

null 2 Sep 28, 2022
Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP

Propel2 Propel2 is an open-source Object-Relational Mapping (ORM) for PHP. Requirements Propel uses the following Symfony Components: Config Console F

Propel 1.2k Dec 27, 2022
[READ-ONLY] A flexible, lightweight and powerful Object-Relational Mapper for PHP, implemented using the DataMapper pattern. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP ORM The CakePHP ORM provides a powerful and flexible way to work with relational databases. Using a datamapper pattern the ORM allows you to m

CakePHP 146 Sep 28, 2022
A data mapper implementation for your persistence model in PHP.

Atlas.Orm Atlas is a data mapper implementation for persistence models (not domain models). As such, Atlas uses the term "record" to indicate that its

null 427 Dec 30, 2022
Doctrine Object Relational Mapper (ORM)

3.0.x 2.9.x 2.8.x Doctrine 2 is an object-relational mapper (ORM) for PHP 7.1+ that provides transparent persistence for PHP objects. It sits on top o

Doctrine 9.5k Jan 2, 2023
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Idiorm http://j4mie.github.com/idiormandparis/ Feature/API complete Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it wil

Jamie Matthews 2k Dec 27, 2022
Convention-based Object-Relational Mapper

Corma Corma is a high-performance, convention-based ORM based on Doctrine DBAL. Corma is great because: No complex and difficult to verify annotations

Michael O'Connell 30 Dec 20, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jens Segers 6.3k Jan 5, 2023
Easily exclude model entities from eloquent queries

Laravel Excludable Easily exclude model entities from eloquent queries. This package allows you to define a subset of model entities who should be exc

H-FARM 49 Jan 4, 2023
Driver to seamlessly integrate the Backup Manager into Laravel applications.

Laravel Driver for the Database Backup Manager This package pulls in the framework agnostic Backup Manager and provides seamless integration with Lara

Backup Manager 636 Dec 30, 2022
[Package] Multi-tenant Database Schema Manager for Laravel

Multi-tenant Database Schema Manager for Laravel Tenanti allow you to manage multi-tenant data schema and migration manager for your Laravel applicati

Orchestra Platform 580 Dec 5, 2022
Satis composer repository manager with a Web UI

Satisfy Satis Composer repository manager with a simple web UI. Introduction Satisfy provides: a Web UI: A CRUD to manage your satis configuration fil

Ludovic Fleury 470 Dec 28, 2022