Another thing bad about PDO is that it cannot be subclassed in any meaningful way to introduce features like query caching. I could rant some more but what's the point?
PHPPgSQL is a SourceForge.Net project. Here is what it does:
- Implements the Iterator interface so query results can be iterated through with foreach. This is in my opinion the best and most intuitive interface for row iteration.
- Relies on and extensively uses query parametrization. Not only does it improve performance by allowing query plan caching, it is also a defense against SQL injection security problems.
- Query plan caching significantly improves performance of complex SQL queries. If it is used with persistent database connections (as is recommended), query plans will only be calculated once and then reused across all PHP script invocations communicating with the same backend.
- Is integrated with Memcached, performing query data caching on SELECT queries. This means that frequently executed queries never even touch the database but are quickly returned.
PHPPgSQL is a light-weight class in terms of code size but is definitely not light-weight in terms of memory and resource usage. It trades memory for speed. I'll emphasize it again: query parametrization is the single most important thing here - without it there the benefits of using PHPPgSQL will be greatly lessened.
PHPPgSQL documentation is included but also available here.
Here's a simple example:
$q = new PHPPgSQL("SELECT comment FROM forum WHERE forum_id=$1 AND user_id=$2", $forum_id, $uid);
foreach ($q as $row)
var_dump($row);
echo "There are {$q->reccount} records.\n";
Depending on future interest in the library, I will develop or refresh PHPPgSQL with my future development versions.
(of course, PHPPgSQL can use all these nice technologies because it doesn't even pretend to be a generic, database-agnostic wrapper, unlike PDO)
Post your comment here!
Comments are subject to moderation and will be deleted if deemed inappropriate. All content is © Ivan Voras. Comments are owned by their authors... who agree to basically surrender all rights by publishing them here :)