I Fought MDB2 and MDB2 Won
If you don’t understand it, don’t worry about it, I just need to vent.
Let’s get this out of the way first: I am *not* a programmer. I kick around in code, but the concepts of pointers and object orientation make my head spin. I want to get the basics of a language, get some libraries and code snippets and put them all together into a simple database app.
I wrote a gift list registry program for our family to use, and some other people have asked about using it. It’s not set up for multiple families, so I thought I’d try writing a new version. The first thing I thought was that I’d try something new like Ruby On Rails.
I got the latest version of Ruby and Rails and got started. Well, it turns out that 99% of the books, tutorials and sample code is written for version 1.x. I stupidly listened to the guys on the Ruby site when they said to download version 2.x. 2.x has been out for over a year and there is very little in the way of practical help. The geek-manuals (which are deliberately written so that only people who already know what they’re talking about can understand them) were useless to me (see paragraph 2). Version 2.x is incompatible with version 1.x, but only subtly so. I spent 90% of my time trying to figure out how to translate the basic “hello world” type examples from one version to the other, and trying to figure out what the error message on my screen means when (I am serious here) there are TWO google hits for this message, and both of them are to the source code for Rails. So, do I develop a site in a deprecated language and just wait for the mandatory rewrite?
Just like my multiple aborted Linux installs, I just gave up.
Fast forward six months. I want to get this program going so I decide I’ll stick with PHP. I have a passing knowledge of PHP. The original gift thing is written in PHP4, so I thought this would be the easy way to go. A bit more labour intensive perhaps, but stick with what I know.
Well. PHP5 is out, and of course you’d have to be a slobbering neanderthal to use PHP4 (at least that’s what the developers seem to imply). I try to upgrade my web host to PHP5. After all, it’s backward compatible, right?
It took 2 days to get the move from PHP4 to PHP5 to not break my existing website installs (sorry Lyndon).
That got sorted out, and now I had a shiny new piece of paper to scribble on. I started out by going to look for libraries to help me do some of the heavy lifting: user management and data presentation. I looked at bunches of user authentication scripts (sidenote: SourceForge really needs to clear out the “haven’t been developed in over 7 years” projects).
It took forever to get one to work on my shared-hosting server, because I don’t have access to the PHP directories, so I had to figure out how to manually install the package, getting all the pathing right, in a subdirectory of my site root and then get the environment to find it.
I started looking for a data presentation library, and PEAR::DataGrid seems to be an obvious choice. There are two ways to access a mysql database in PEAR, PEAR::DB or PEAR:MDB2. DB is deprecated. There are dire warnings everywhere about how it isn’t developed anymore and it has been superceded my MDB2. No one, however, has told the rest of the internet about this.
In a situation that exactly mirrors the Ruby on Rails upgrade fiasco, there are next to no practical tutorials on how to use MDB2. All of the sample code uses DB. All of the downloadable libraries and source code are for DB.
After another couple of days of whacking away at it, I actually managed to get MDB2 and PEAR::DataGrid to work together. I saw my data in a nice table. YAY!
Then I decided to try using PEAR::Pager to split it into pages.
In another wonderful example of communication, the developers are the only ones who seem to care that DB is deprecated. Try to find a good example on the net of using ONLY MDB2 to display an entire database table in PEAR::Structures_Datagrid using PEAR:Pager. (Don’t be a smartypants and post links. Yes, I know there are one or two, I found them, and they stink.)
I did get it to work. I actually got this whole silly table in a web page with 10 records per page, sortable headers and pagination links. YAY!
Then I tried to add in the authentication libraries.
Whoops. They use DB. All of them. So, I can mix and match a deprecated connection library with the “correct” one all through my app, or I can rebuild the whole app using just the deprecated connection library despite the doom and gloom warnings of the PHP developers, or I can just put a gun in my mouth and save myself the effort.
I honestly don’t think I have ever felt this completely helpless. This should be a total no-brainer application. 15 years ago I would have had it running in FoxPro in 3 hours. Now I feel like I’m fighting the tools the whole way and the tools are winning.
Bah.
Yea… you are fighting the tools… the pear auth libs suck… the datagrid and mdb2 rock! Just hand code the auth part of the app it will take a couple of minutes.