Bill Karwin wrote:
Hi Colin, I worked on Zend_Db quite a bit during 2007.  The COLUMN fetch
mode was not supported when I joined the project, and I don't recall anyone
mentioning any interest in it, so I didn't bother with it when there were so
many other tasks to do that were in high demand.

So: not an oversight, not by design, just never got around to it.

Cool. I only tested it very breifly, but it seemed to work.

In actual fact, I think I'm generally going to abandon changing the fetch mode as it seems to me to be a little dangerous as there doesn't seem to be a way to get the current fetch mode and reset the object when you are done (e.g. to leave it in a known state.

The alternative is to always call the setFetchMode before any call but that seems a little wasteful code wise.

Perhaps setFetchMode could return the current fetch mode such that it coudl then be restored?

e.g.

$old_mode = $db->setFetchMode(Zend_Db::FETCH_COLUMN);
$db->fetchAll($sql);
$db->setFetchMode($old_mode);

Or perhaps even a one-shot version:
// $db has fetch mode == foo
$db->setNextFetchMode(Zend_Db::FETCH_COLUMN);
// $db has fetch mode == Zend_Db::FETCH_COLUMN
$db->fetchAll($sql);
// $db has fetch mode == foo again.


I can set the fetch mode to a known mode in my code that gets the instance of the connection, but this would be more generic.

Likewise there was no purpose for using PDO constants instead of Zend_Db
constants with identical name and value.  There was no functional need to
change them in code that was internal to Zend_Db, and no justification for
spending time on it when there was a long list of other things to do that
would result in more substantial benefit.

Well I agree with the reasoning and fully appreciate the "why" :)

While there is no need to change the constants, I think it's wise. PDO could be compiled differently and change the values of it's constants. While this is very unlikely it would present some really odd bugs if it ever did happen.


The patch for this is in the previous mail if someone wants to commit it.

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

Reply via email to