Wednesday, 5 September 2012

Get rows from multiple statements

While I was trying to return rows from a SELECT statement at the end of a list of multiple statements passed through PHPs PDO with MySQL I ran in to a few problems.

1.) First, if you send multiple statements, you have to go through each rowset that is returned for each statement. This is accomplished using the nextRowset() function. Which is talked about on a StackOverflow question and discussed in depth on this Internet Super Hero blog post.

It seems that the standard pdo-mysql driver cannot do this, or has some other difficulty. The suggested solution is using the pdo-mysqlnd patch. Sounds simple enough with the instructions here, but I am running MAMP and so have a separate PHP version running for MAMP. Luckily there are instructions for upgrading MAMP's PHP on David Golding's blog post Upgrading PHP in MAMP.

2.) I had an issue with the error:
cannot open /Applications/MAMP/Library/build/ No such file or directory at /Applications/MAMP/Library/bin/apxs line 218.
during the configure process. As noted in the comments (by: Khang Nguyen) from the previously mentioned blog post the solution is changing:

3.) And for the purpose of compiling PHP with pdo-mysqlnd we change:


NOTE: For the following I use "/opt/local" since I use MacPorts, you might have to use something different like just "/opt".

4.) Next error:

configure: error: libjpeg.(a|so) not found.
Solution: Change:
'--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-freetype-dir=/Applications/MAMP/Library'
--with-jpeg-dir=/opt/local --with-png-dir=/opt/local --with-zlib --with-freetype-dir=/opt/local
5.) Fix t1lib error. Make sure t1lib is installed:
sudo port install t1lib
6.) 'configure: error: Cannot locate header file libintl.h'
6.) Error: 'configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.'

If you need to install:
sudo port install php54-imap

Uggghh, know what? Just update MAMP, it works now! :p

Hayley Smith on Burning Man

"No, it's all about a bunch of naked morons drinking and doing lots of drugs."