Total Rows In MySQL Query ‘Trick’

Background: I wrote this post last week, after discovering what I thought was a nifty trick. Shortly afterwards, I found contradicting evidence that suggested the traditional route of using a separate query of COUNT(*) was faster, and/or it depends on your individual database design. Instead of deleting the post, I figured I should publish it anyway, along with a link to the article that I read, so that those who give a crap about this sort of thing can make their own mind up.

One of the benefits of working on and releasing — apart from giving me an active place to review (I typed rev.iew first, damnit) — was the excuse it gave me to learn more stuff. I like learning stuff.

Here’s a nifty little MySQL ‘trick’ that I discovered, that helps cut down on unnecessary bloat. When doing pagination, I’d always create the query to deliver the results and a second query to COUNT() all rows, and this adds extra load time. Using SQL_CALC_FOUND_ROWS and FOUND_ROWS(), we still have two queries but the second is faster because because the result set need not be sent to the client (source)

Pop SQL_CALC_FOUND_ROWS in to your query just after the SELECT, and do another query directly afterwards using SELECT FOUND_ROWS(); E.g.

$query = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM `members` LIMIT 0, 15");
$total = mysql_query("SELECT FOUND_ROWS();");

Assuming there’s 50 members in the members table, we now have the result set for 15 members in $query and the total row count in $total (use mysql_result() to access the number directly). Nifty, huh?

PHP Mail Form Update

I’ve just released version 2 of my free PHP mail form and heartily welcome feedback from those currently using version 1 of the script. (That means: someone hurry up and test it so I don’t have to! Kidding, kidding…)

Is Your Pipe Wrong?

Something that came up in conversation this weekend (well, this is what happens when you get more than one geek in a room)… on many keyboards, the pipe is in the wrong place.

The pipe — that’s | to you non-geeks — is just to the right of the left-hand shift key on UK keyboards. Position may vary slightly but you get the idea. Now, on some UK keyboards, even though the pipe character appears when pressing that key, more times than not it’s actually the vertical broken bar that’s printed on the keyboard. It’s a ready-made typo just waiting to trip you up!

Are you following? Probably not, here’s a visual (thanks to for the keyboard image):

vostro keyboard

And indeed, this is quite common. Rachael‘s pipe is in the right place on her Asus EEE, but Amelie‘s Toshiba is wrong, as is a Compaq keyboard and several Dells at her work.

So, where’s your pipe, and is it printed correctly?

Super Productive

I’ve been super productive, and answered all of my questions! No, not really, Rachael did it. Teehee.

Furry Friday: Innocent

I wanted to give you all piggie pics today, but they’ve not sat still for long enough and the light has been terrible, resulting in absolutely zero usable pictures. Anyway, settle for catties… (well, one catty):

fudgie face

Fudge has such an innocent face, until you catch him stealing your chicken out from under the grill (for real!) It’d be quite expensive to experiment with that in an attempt to get a picture though…


After spending the past couple of years or whatever blasting the shit out of twitter because it’s encourages inane BS, I actually got one. To reserve my username, of course, no other reason :P

Animal Crossing: Lets Go to the City Review

I can’t remember when I first got hooked on Animal Crossing… it must have been not long after the DS version came out (“Animal Crossing: Wild World“) because I’d never heard of it back when I spent weekends hard-wired in to the GameCube. I know that I’d read online that it was similar to Harvest Moon, and as a fan of Harvest Moon: AWL (<- review) I must have bought in to the series then.

In reality, Animal Crossing is not that much like Harvest Moon at all. Sure, you have a little person that you control, and you can talk to people, but that’s where the similarity ends. Where Harvest Moon is about growing crops and making money, Animal Crossing is about planting flowers and making friends. The DS version of Animal Crossing is almost dependant on you logging in every day, because failure to do so causes flowers to die and cockroaches to take over your house.

When you’re not prettifying your town, entertainment can be found in shopping; fishing; hunting bugs; and digging up fossils. Relationships with townies are quite important and get you all-important ‘pictures’ which both decorate your house and increase your Happy Room Academy score, a means of testing how well you lay out your furniture (amongst other things).

Animal Crossing: Lets Go to the City is not really that different from Wild World (DS). Everything is bigger — obviously, you’re viewing on a much bigger screen — and the town layout allows for more landscape features… multiple levels, a second smaller waterfall, more space for houses; but the games are nonetheless identical in game play. The graphics are bold and colourful, and surprisingly ‘crisp’ (I’m not sure what I expected though).

When you first start the game, you’re on a bus with Rover, and you’re asked if you want to move a Wild World town over to the Wii. I’d be interested in trying this out eventually (I like my “Faraway”) but picked ‘new town’ to get a basic grasp on things. After giving Rover your name, the time/date, and choosing your gender, Kapp’n informs you that your bus has arrived. Cue an introductory period of about an hour, which you’ll spend working away for Tom Nook, meeting your new neighbours, buying your first tools, etc. All probably sounds very familiar to DS players, but there’s one key difference: you get to choose your own house. From a choice of four houses in different locations, with slightly different décor, you are able to begin the process of making a mark on your town.

Given that the game is so similar to the DS version, I can see me liking it just as much. There are some old annoyances around still (like having to talk to go through the same conversation every time you visit Nook’s, or every time you donate a fossil) but others are removed (after you identified all of your fossils at the museum, Blathers doesn’t ask you if you have any more to identify, the conversation takes you back to the main menu).

I need to play it more to give a more detailed review, but first impressions are good, and I’d suggest Wild World owners buy it despite the similarities just for the sake of owning another piece of cute Animal Crossing merchandise.

Dying Girl is Not Dying

I don’t know of how many of you will recall this, but when I gave out my last Pants Award, the recipient turned around and told me that I shouldn’t have criticised her site because she has terminal cancer. I’m not sure in what way the two are related — cancer doesn’t cause you to have a shite website — but the site was shortly deleted nonetheless. She then said (for some kind of dramatic effect I guess) I just told you I am going to die

Fast forward a while, to this month. I’d forgotten all about her. In theory, she should be dead by this point, really. I mean, I didn’t believe her for a second and it wouldn’t be the first time that someone online had made up bullshit to try and win sympathy, but one likes to err on the side of caution with these things, you know? Terminal cancer is after all is said and done, “terminal”. That means they’re going to die.

Lo, how surprised was I then, when someone pops a comment on the Pants entry to tell me that Ms. Amarilys is alive and well. In fact, her plurk even shows a consistent timeline of posting, apart from a short break of 4 days for “surgery”. Given that I was in hospital for 4 days under minor circumstances, I somehow doubt that her doctors managed to cure terminal cancer and have her out of hospital and ready to post again within that teeny tiny timespan.

Cancer: it’s a horrible disease. I’m glad that through so much campaigning and support from charities we have the kind of cure rates that we do. It’s not perfect, people are still dying, but I hope that some day this won’t be the case. Given that I was there to watch my Nan die of lung cancer when I was just 14… it sickens me that someone could be so screwed up in the head that they feel using terminal cancer is necessary… because they’re a little embarrassed about a FICTIONAL fucking award. Get a grip on reality for crying out loud.

Oh, and your website still sucks.

I’m a Whiny Cow

I’ve just sent in a complaint email to the Mars company/customer care people, because every Malteser I’ve had so far from a bag I bought today has tasted like plastic. I just wanted some tasty, crispy chocolate, jeez. :( Fake SERP Referrals Are Pissing Me Off

Melissa and I had a short chat about search results in our stats a while ago. Long story short, a whole bucketload of search result click-throughs were showing up in our hits that were either a) irrelevant to our sites or b) were bullshit, because we weren’t ranked for that term anyway. This wasn’t particularly bothering me at the time — although obviously annoying — so I left it at that.

However, with the launch of I’m obviously keeping an eye on referrals, hits, SERPs etc. I want the site to do well for the benefit of the users, not just for me. This is becoming impossible with sending a fake/spoofed SERP referral every hour. My search engine referrals a littered with crap so it’s hard to tell fact from fiction, and I can’t even begin to imagine how that’s having an affect on hit counts/etc. The bastard of it is, Microsoft admitted to the referrer/cloaking spam so it’s not even a bug (this is intended behaviour!)

I’m sorely tempted to start blocking the bot. Despite the fact that this would eradicate any possibility of ranking in Live — oh noes, what a shame — at least my blood pressure would return to a sane level!

Christmas Wishlist

Because I’m a materialistic twat, and know full well that at least two people buying me gifts this year read my website, I’ve compiled a short list of things that I’d like for Christmas. :D

Thanks in advance :P Christmas Contest