Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP and unixODBC

PHP and unixODBC
Thread Tools
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Jun 30, 2004, 06:23 AM
 
Does anyone have experience using unixODBC with PHP? More specifically, using the iSeries Access ODBC driver for linux with it.

OK, I'll explain.

Using unixODBC with the aforementioned driver to access data on an AS400 (using OS400 version 4 release 5) works swimmingly from the command-line, using isql. However, as soon as I call the same queries from PHP, some of the data comes back as EBCDIC, but some as ASCII (I want the ASCII, but not EBCDIC). I had presumed it was a problem with the driver, since OS400 version 5 release1 is the minimum officially supproted OS, but since it works from the commandline, I'm a bit stumped as to why the exact same thing doesn't work with PHP.

Anyone have any ideas?
( Last edited by Black Book; Jun 30, 2004 at 06:46 AM. )
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Chris O'Brien  (op)
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Jun 30, 2004, 06:34 AM
 
Ah bollox.
I'd already sorted the problem by setting the value of Force Translation to 1 for the DSN, but it just wasn't being reflected in PHP because I hadn't restarted Apache (didn't think I'd have to, but just did and now everything works).

I'd been tearing my hair out for a week about this.

Ah well. never mind.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
larkost
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Jun 30, 2004, 10:41 AM
 
Just to be clear... this is all running on a linux box, yes?

If not, I need more information, because I desperately want to ODBC connect from my Mac to DB2 on an AS/400.

Even if this is on Linux, do you have sources for how-to's? I will have to do this shortly.
     
bluedog
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jun 30, 2004, 12:16 PM
 
Thanks for your followup. Its good to hear a resolved problem. I will likely be implementing some ODBC/PHP stuff from a 4D database and this may or may not help me out of a similar prob!
     
Chris O'Brien  (op)
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Jun 30, 2004, 05:20 PM
 
Yeah, this is all running on a Slackware 9.1 box. The driver is available at ibm's website, but the only supported distro is Redhat (comes as an rpm). This caused a bit of a problem with installation, so I had to do it manually (made it into a tarball and then went through some more jiggery pokery.

I'm quite sure it could work from OS X - the RPM gives a list of dependencies, so you know what to get from fink

unixODBC is available for OS X as-is though, so that bit's easy (then just compile PHP -with-unixODBC).

When I get into work in the morning I'll post a list of sites which were helpful, and I'll lend as much of a hand as you need
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Chris O'Brien  (op)
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Jul 1, 2004, 05:11 AM
 
OK.
You can get unixODBC for OS X via fink. The homepage is here and the sourceforge project here. As you can see it's still in active development (the last update was exactly a week ago).

So once it's installed then compile PHP with the --with-unixODBC option as I mentioned before.

Then it's a matter of installing the IBM driver which can be found here.
Set up your DSN, and make sure Force Translation is set to 1
If the RPM doesn't work (because, like was the case with me, your RPM manager is too old and you can't be arsed updating it), you can go here to see what else needs to be done.

I should point out, that PHP can be compiled with DB2 support tiself (--with-ibm-db2), which makes all of this unnecessary, unless you want to use ODBC and other databases (like me). See here for more information.

I'm actually going to experiment with the 'native' DB2 support in PHP (I 've only glanced through the previous link, and don't know it in depth.

To reiterate. I chose unixODBC and the linux driver from IBM rather than compiling PHP --with-ibm-db2 because I was already using unixODBC. I think I'm going to give the former a try at some point, just to kind of 'benchmark' it. As far as I can remember, the odbc functionality provided by compiling --with-ibm-db2 uses a lot of the code from unixODBC anyway...

I'd recommend not doing what I did on OS X, unless you have need to, and going with the --with-ibm-db2 option. I don't know enough about it yet to say if that's a well founded recommendation, but when I persuade work to let me have a mac instead, I'll test it out (or someone else on here might've already).

Hmm, that was all rather quick fire...

Cheers.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:50 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,