PHP'ersist (Persistence Layer for PHP)

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Ainathar
Forum Newbie
Posts: 3
Joined: Sat May 31, 2008 11:22 am

PHP'ersist (Persistence Layer for PHP)

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP'ersist (Persistence Layer for PHP)

Post 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?
(#10850)
Ainathar
Forum Newbie
Posts: 3
Joined: Sat May 31, 2008 11:22 am

Re: PHP'ersist (Persistence Layer for PHP)

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP'ersist (Persistence Layer for PHP)

Post 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 ...
(#10850)
Ainathar
Forum Newbie
Posts: 3
Joined: Sat May 31, 2008 11:22 am

Re: PHP'ersist (Persistence Layer for PHP)

Post 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.
Post Reply