Page 1 of 1

PHP'ersist (Persistence Layer for PHP)

Posted: Sat May 31, 2008 11:31 am
by Ainathar
Hi all, I'd like to suggest you an API i found at sourceforge.net. PHP'ersist is a persistence layer for PHP that has a built-in support to MySQL and Firebird. This API is open source under GPL.

PHP'ersist => http://sourceforge.net/projects/phpersist
PHP'ersist Wiki Documentation => http://phpersist.wiki.sourceforge.net/Doc


Also PHP'ersist API has table collections support with a restriction class used to create the data collections from a table. The API free the coder from write any SQL statement.

[]'s

Re: PHP'ersist (Persistence Layer for PHP)

Posted: Sat May 31, 2008 12:16 pm
by Christopher
The interface certainly does not seem very elegant:

Code: Select all

cRestrictionFactory::addRestriction("description",sOper::MORE,1);
$collection = cCollectionTableFactory::getCollection('TAB_ACCESS',cRestrictionFactory::getRestrictions());
$cont = 0;
while($cont < $col->getSize()){
   $access = $collection->elementAt($cont);
   echo $access->getDescription()."<br>";
   $cont++;
}
I think you meant "code" in your addRestriction call. What happens if you have two tables with a 'code' column -- given that you are using a static call?

Re: PHP'ersist (Persistence Layer for PHP)

Posted: Sat May 31, 2008 12:30 pm
by Ainathar
What happens if you have two tables with a 'code' column -- given that you are using a static call?
=> Once u called cCollectionTableFactory::getCollection all restrictions are delete. And then you are free to use the class again;

Code: Select all

 
 cRestrictionFactory::addRestriction("code",sOper::MORE,1);
 $collection = cCollectionTableFactory::getCollection('TAB_ACCESS',cRestrictionFactory::getRestrictions());
 
 cRestrictionFactory::addRestriction("code",sOper::MORE,1);
 $collection2 = cCollectionTableFactory::getCollection('TABLE2_WITH_CODE_COLUMN',cRestrictionFactory::getRestrictions());
 
I think you meant "code" in your addRestriction call.
You're right. Thx. UPDATED.
The interface certainly does not seem very elegant:
And how do you think it could be? Thx for ur comments , this helps to improve the codes.

[]'s

Re: PHP'ersist (Persistence Layer for PHP)

Posted: Sat May 31, 2008 2:07 pm
by Christopher
How does the persistence work? Is is automatic in the destructor or is there a save() method?

I would prefer a cleaner, fluent interface like $access->find('code>', 1); that does essentially way yours does. You should take a look at the SQL classes that Jcart and pytrin are doing for the Skeleton framework ...

Re: PHP'ersist (Persistence Layer for PHP)

Posted: Sat May 31, 2008 3:43 pm
by Ainathar
How does the persistence work? Is is automatic in the destructor or is there a save() method?
There are 3 methods essentially (persist[insert and update], select and delete). So it's not automatic.

I would prefer a cleaner, fluent interface like $access->find('code>', 1); that does essentially way yours does.
That code you saw it's used to create a collection from a table. For this purpouse your opinion is good. But if you want to select a single record from a table to an object, so it's very similar, something like:

Code: Select all

 
$access = new TAB_ACESS(1);
$access->setDescription("SOME DESCRIPTION");
$access->persist();
 
or

Code: Select all

$access = new TAB_ACESS();
$access->setCode(1);
$access->select();
$access->setDescription("SOME DESCRIPTION");
$access->persist();
 
You should take a look at the SQL classes that Jcart and pytrin are doing for the Skeleton framework ...
I'll take a look.

Thx 4 ur reply.