phpersistence: PHP Object Persistence
November 29th, 2004I stumbled upon "Phpersistence":http://www.phpersistence.org/ today, a PHP4 library attempting to duplicate the functionality of Java's Hibernate.
I jumped for joy. Then I cried.
The code is actually pretty well written. It's capable of allowing normal objects that haven't extended any special classes to persist. But there are some pretty hefty problems.
99% of all the setup for what goes where and why is handled by a configuration file written in PHP. This configuration file is parsed by a PersistenceConfiguration class, the name of which is hard coded in the Persistence class. This means that you can't feed configuration to Persistence in any fashion other than this PHP file. And this PHP file is a bit complicated. That's a bit silly, but workable.
The DB connection can be pre-initialized or the class will initialize it for you. This seems to be pretty flexible. Unfortunately, the class itself actually only accept the pre-initalized format and some of the class init routines handle creating a pre-initialized object if it isn't created already. The pre-initialized class is stored in a GLOBAL variable. Why? Why? Why? Why? In order to define the parameters for the DB connection, one must use a series of DEFINEs. Why? Why? Why? Why? But… so what. So there's a silly global variable floating around. Big deal. The next part is the kicker.
You only have the ability to define ONE database connection. This means that all of your tables within a particular configuration of Persistence must be in the same database, on the same database server using the same username and password combination. While I'm sure the majority of users will probably use it in that fashion, it just seems silly to me to code that limitation in when it could be avoided so easily. And, since the database connection is found via a global variable, you couldn't even get around the problem with multiple instances of Persistence and multiple configuration files.
So, if you need simple object persistence, and you don't really care about global variables or silly DEFINEs and you are willing to store all of your persisted objects in a single database, "Phpersistence":http://phpersistence.org might be what you're looking for.




















Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks