Thursday 31 March 2011 2:32:33 am
Hi Benjamin, Gaetano, Here is an initialization stub, easily embeddable in a dedicated method :
public static function initializeEzcPersistentSession()
{
if ( !self::$initialized )
{
// @FIXME : make this code DBMS-agnostic
$dbURI = "mysql://";
$dbURI .= eZINI::instance()->variable( 'DatabaseSettings', 'User' );
$dbURI .= ':' . eZINI::instance()->variable( 'DatabaseSettings', 'Password' );
$dbURI .= '@' . eZINI::instance()->variable( 'DatabaseSettings', 'Server' );
$dbURI .= '/' . eZINI::instance()->variable( 'DatabaseSettings', 'Database' );
ezcDbInstance::set( ezcDbFactory::create( $dbURI ) );
$session = new ezcPersistentSession( ezcDbInstance::get(),
new ezcPersistentCacheManager( new ezcPersistentCodeManager( "extension/ezforumtools/classes/po/" ) ) );
ezcPersistentSessionInstance::set( $session ); // set default session
self::$initialized = true;
}
return ezcPersistentSessionInstance::get();
} and here is a usage stub :
$session = eZForumTools::initializeEzcPersistentSession();
$q = $session->createFindQuery( 'eZForumModeratedEntry' );
$q->where( $q->expr->eq( 'contentObjectId', $q->bindValue( $objectId ) ) );
return $session->find( $q, 'eZForumModeratedEntry' );
These are stubs, to be wrapped in lazy initialization ideally,
Hope it helps, Cheers,
--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board
eZ Publish Community on twitter: http://twitter.com/ezcommunity
t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye
|