pdo::mysql and unbuffered queries

pdo::mysql and unbuffered queries

am 06.10.2007 02:47:06 von Thomas Tschernich

Hello there,

I tried using pdo (www.php.net/pdo) as it would be nice for my projects to
be portable to another database systems, but quickly ran into problems.

The lesser important: One time, there was a simple typo in one of my queries
and I got an error that php is not able to save session variables at the
given path - I'm not joking! I worked several hours to solve that session
problem just to realize the query had a bracket to few. I already got other
errors in my queries where I was given a correct error trace, this is quite
confusing.

The bigger important: I was not able to build nested queries. For example:
Imagine you are running a bulletin board, and you have to select 10 posts in
a thread. To each post, there is another information which is needed to be
resolved from the database, so I have 1 more query for each of these posts.
This is possible only with one of two workarounds .. I can use
pdoStatement::fetchall() to instantly load all result rows into one array
and afterwards looping through this array. After years of programming in
"classic php-mysql I am not used to this method at all and I do not think
this is nice programming in concerns of memory usage as this array may
become very big. The other option is to force queries to be buffered via the
constantPDO::MYSQL_ATTR_USE_BUFFERED_QUERY, but then I would gave up
independence as such code is not anymore compatible to other dbms than
mysql.
In simple words: Can I have best of both worlds?

Big thanks in advance,
Thomas Tschernich

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: pdo::mysql and unbuffered queries

am 08.10.2007 02:55:43 von dmagick

> I tried using pdo (www.php.net/pdo) as it would be nice for my projects
> to be portable to another database systems, but quickly ran into problems.
>
> The lesser important: One time, there was a simple typo in one of my
> queries and I got an error that php is not able to save session
> variables at the given path - I'm not joking! I worked several hours to
> solve that session problem just to realize the query had a bracket to
> few. I already got other errors in my queries where I was given a
> correct error trace, this is quite confusing.

Can't comment on that one but if you can prove it in a small test
script, post a bug report on http://bugs.php.net

> The bigger important: I was not able to build nested queries.

Post your code. I doubt that the guys that developed PDO would stop
something like this.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php