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
PHP'ersist (Persistence Layer for PHP)
Moderator: General Moderators
- 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)
The interface certainly does not seem very elegant:
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?
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++;
}(#10850)
Re: PHP'ersist (Persistence Layer for PHP)
=> Once u called cCollectionTableFactory::getCollection all restrictions are delete. And then you are free to use the class again;What happens if you have two tables with a 'code' column -- given that you are using a static call?
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());
You're right. Thx. UPDATED.I think you meant "code" in your addRestriction call.
And how do you think it could be? Thx for ur comments , this helps to improve the codes.The interface certainly does not seem very elegant:
[]'s
- 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)
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 ...
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)
Re: PHP'ersist (Persistence Layer for PHP)
There are 3 methods essentially (persist[insert and update], select and delete). So it's not automatic.How does the persistence work? Is is automatic in the destructor or is there a save() method?
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:I would prefer a cleaner, fluent interface like $access->find('code>', 1); that does essentially way yours does.
Code: Select all
$access = new TAB_ACESS(1);
$access->setDescription("SOME DESCRIPTION");
$access->persist();
Code: Select all
$access = new TAB_ACESS();
$access->setCode(1);
$access->select();
$access->setDescription("SOME DESCRIPTION");
$access->persist();
I'll take a look.You should take a look at the SQL classes that Jcart and pytrin are doing for the Skeleton framework ...
Thx 4 ur reply.