Programming Trumps Children03/09/09 @ 6:02PM EST
posted by will

Also note that the count() function was included in the for loop to account for any variation of Aviv's attention span which may occur during the course of said argument.
It's also of note that this is type of exciting thing which happens as one waits for a reflux to finish up.
PHP won this
A recursive acronym
It is brilliant
Godspeed.
[Comments: 0][Tags: code]
MySQL select all is bad idea07/25/08 @ 7:29PM EST
posted by will
When I started writing my site with PHP/MySQL, my SQL SELECT queries would generally consist of:
SELECT * FROM
tablename WHERE
condition
I would then have that query spit out into an array. The next step would be to sift through and pick what I wanted. Maybe I wanted the data from the 2nd and 4th columns, so I would pull out $data[$j][2] and $data[$j][4] ($j is my counter). It works just fine, no problem... yet.
Fast forward a few months when I have implemented some new features, and replaced some old functions. I no longer need some of these columns, so let's delete them from the database, no functions are using them. Kaboom; things just went amuck. Why? Nothing was using that column. Now the data I need is in $data[$j][3] instead of $data[$j][4] and all my code is pointing to the wrong stuff.
It's possible to patch it up by going through all the code, and changing the fours into threes, but that's short-term. You should really be refining the queries to avoid such problems, by using this type of query:
SELECT
columnname,
columnname FROM
tablename WHERE
condition
This would be the smarter way to go about this. I wish I had thought of this, now I need to go look through all my code and make some changes; it's for the better though. I'm not really sure how to go about testing which is more efficient (where you run something 10k or so times and record the average time for different methods), but has this been done before?
And for the record, I think the scene in this image is a
great idea.
Photo:
Flickr
Godspeed.
[Comments: 2][Tags: code]