eZ Community » Forums » eZ Publish 5 Platform » Which database persistence layer

Which database persistence layer

Which database persistence layer

Tuesday 23 April 2013 3:27:29 pm - 25 replies

Hi everybody,

I wan't to access tables in the same database as my eZP5 setup, in the same way we did before with the eZPersistentObject class, but I'm a bit confused about the tools available on eZP5:

eZPersistentObject: Seems available only in the legacy stack
ezcPersistentObject: Looks like it can be used as a service from the new stack
Doctrine: Was the new layer listed in an early announcement of eZP5, but not seems included yet

Can anyone advice me about the most sustainable method ?

Many thanks,


Modified on Tuesday 23 April 2013 3:29:51 pm by Romain Petit

Thursday 14 November 2013 3:47:51 pm


i see your problem, i stumbled upon that aswell.
I put the PersistentObject's definition files in a subdirectory called "Definitions"

so i have - to comply with zeta component's tutorial -

-- contains the class representing the PersistentObject
-- contains the ezcPersistentObjectDefinition. Pay attention to use the namespaced version of the ClassName in  

$def->class = "Namespace\BundleName\Person"


you then pass the path where your definition files reside to the constructor of ezcPersistentCodeManager:

$path = realpath( __DIR__ . "/../Definitions/" );   
$codeManager = new ezcPersistentCodeManager( $path );
$persistentCacheManager = new ezcPersistentCacheManager( $codeManager );
$db = ezcDbFactory::create( 'mysql://user:pass@localhost/databaseName' );  // <-- that's to be replaced, topic of this discussion here
$session = new ezcPersistentSession(    $db,   $persistentCacheManager    );

in the Controller also make sure to pass the "Namespaced" ClassName, as in

 $q = $session->createFindQuery( 'Namespace\BundleName\Person' ); 

to create a new "Person" Object i have a 

 use Namespace\BundleName\Person;

before the class definition of the controller, so i can - later on in the controller code - instantiate a "Person" Object by a simple

 $user = new User();

hope that helps! 
Does Jerome's tip work for you? 

Ps: ezoe keeps inserting strange "<span>"s into my postings, those are to be ignored!

Modified on Thursday 14 November 2013 3:49:31 pm by Rene Hrdina

Thursday 14 November 2013 4:13:03 pm

Thank's for your answer !!

Ok i understand the way you had manage it.

At the begining i've hack code_manager.php so he was looking for the definition in the same directory than the class but for the file with the naming "Person.ezp.php"

I think i will reverse my hack to store the definition like you, even if i have to create the same directory structure under my folder : NameSpace/BundleName/Definitions/namespace/bundlename/person.php

I've take some time to understand like you that we need to do:

 $def->class = "Namespace\BundleName\Person"
$q = $session->createFindQuery( 'Namespace\BundleName\Person' );

For EzcDbHandler, i've just apply the commit in my repository.... As it will come later, it is not a real hack blunk.gif Emoticon

So this is working for me now :

 $this->container->get( 'ezpublish.connection' )->getDbHandler();

Modified on Thursday 14 November 2013 4:16:12 pm by H H

Thursday 14 November 2013 4:24:28 pm

Glad i could help.

I also applied that patch now - originally i wanted to avoid a hack but since it'll be this way in future releases anyway i think i can live with that.

Working fine now - thanks everyone!

Friday 15 November 2013 11:13:42 am

Good that this has now been solved, it's definitely a bit confusing with EzcDbHandler class having the same name in eZ\Publish\Core\Persistence\Legacy namespace as well as the ezcDbHandler from Zeta in global namespace, and they are not interchangeable given there is no inheritance going on here.

One note to add to this thread for those that have not seen it, as mentioned a few places we do aim to switch to using Doctrine over time (and we have actually started working on it). So selecting ezDB vs Doctrine depends on if you want to optimize for db connections right now, or can live with that limitation for a few releases.

Modified on Monday 18 November 2013 3:31:19 pm by André R

Thursday 23 January 2014 6:10:49 pm

- nevermind.

Modified on Thursday 23 January 2014 6:27:16 pm by Rene Hrdina


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from