Deleting Duplicate Rows in MySQL With ONE Query

So you have a MySQL table that, somehow or another (usually on many-to-many relation tables), winds up having rows with duplicate data. Trouble is, finding and deleting these rows most of the time involves several steps that could leave your website with a few errors showing here and here if you don’t perform the updates fast enough. So is deleting multiple duplicate rows in mysql without deleting the first original row possible with just ONE query? Turns out, it is with subqueries, a MySQL feature available since the 4.1 branch. The steps are bit tricky and the query is complex, so I’ve broken it down into several steps that should make it easier to follow. Continue reading

IE6 and Multiple Button Submit Elements

I stumbled across yet another weird issue in Internet Explorer 6 today.  This time it has to do with <button type="submit"> elements and how data is sent back to the server.

<button type=”submit”> vs <input type=”submit”>

You would think both elements would behave exactly the same, because they’re both basically the same thing – the “submit” button on HTML forms.  Turns out that in Internet Explorer 6, they don’t behave the same at all.  Surprise, surprise.  The issue has to do with using multiple submit buttons on a form which can perform different actions:

[Displayed cart contents with editable quantity fields]


Checkout >

Continue reading

Introducing… PHP DataMapper!

phpdatamapperPHP DataMapper is an open-source project I’ve been building and working on for a little while now.  It’s a lightweight Object-Relational Mapper based on the Data Mapper design pattern, setup using one mapper per table.  The primary goal is to make database access one of the easiest parts of building your application instead of the most tedious, and for PHP DataMapper itself to have no dependencies outside the default PHP5 installation so it can be used anywhere, in any application (no frameworks required!).

The project itself hasn’t changed too much recently, but I decided to finally formally introduce this project because I finally got some time to write some decent documentation on how to use PHP DataMapper in in your own application.  Head on over to the PHP DataMapper page to check it out, or just get right into the good stuff with the Getting Started tutorial or the
Usage – Finders example.

More updates and documentation will be coming soon.  If you’re interested in learning more about the project or contributing, please join the Google Group.

UPDATE: Links have been updated to the new home for the project –

In Oklahoma? Come to The OpenBeta “Unconference”

If you’re in or around the Oklahoma City, Oklahoma area, you need to schedule some time for the upcoming OpenBeta "Unconference".  From the event website:>OpenBeta is an un-conference — a participant-driven community event aimed at exposing ideas and creating opportunities by connecting smart, passionate and motivated people with different expertises.

The event will be held on Thursday, October 30, 2008 at the IAO Gallery in downtown Oklahoma City at 7:00pm.  It’s going to be a night of good fun and networking with like-minded technology-oriented individuals in Oklahoma.  I’ll be giving a quick 5-minute lightning talk presentation myself on my upcoming InvoiceMore project and what makes it different from competing online billing and involving services that already exist.

Please consider attending, and have those networking skills ready!

Early Performance Benchmarking is a Disease

Benchmarking and performance concerns should be one of the last things you address while building your application, but it seems as though, in the PHP community especially, it’s often one of the first things novice developers think about.

Any PHP developer who’s been in the community for a while has heard preposterous claims like “use single quotes (‘) for strings instead of double quotes (“), because it’s faster”. That is, faster over the 100,000 or so iterations it took the tester to generate a number sufficiently large enough to justify the claim, with a particular version of PHP, in a particular development environment in which it was tested.

Continue reading

Presentation Slides From Tulsa TechFest 2008

Well Tulsa TechFest is over, and it was a pretty good conference overall. Here are the slides of my presentations at the conference for those who are interested. I have voice recordings of both my presentations too, but unfortunately the digital recorder I bought has no way of directly accessing the files stored in memory to move or copy them to a computer. It just has a line in/out like the old cassette recorders. What’s the point in making a digital recorder if there’s no USB cable or anything to get directly to the files? Huh Sony? Anyways – I didn’t have the cable required to re-record the audio on my computer, so I’ll probably pick one up and make videos of these presentations a little while later. But for now, you can at least enjoy the slides. Continue reading

Reading a FeedBurner Feed with PHP and cURL

Just thought I’d post a quick HOW-TO article on how to get the contents of a FeedBurner feed with PHP, because it’s something I was attempting to do last night that really annoyed me. Since I started this blog here, I decided to narrow another website of mine – – to just distribute some PHP scripts I’ve made and take down the news that was there. I replaced it with a short paragraph explanation and a feed of the recent blog posts here. The problem was, the feed wasn’t displaying, and I couldn’t figure out why.

Continue reading

Speaking at TulsaTechFest 2008

ttf2008-logoAfter anxiously awaiting a response from David Walker, the TulsaTechFest conference Director about an open speaking spot, I just about fell out of my chair today when I finally got the email with a confirmation that I was going to be presenting.  I am very excited about this amazing opportunity, and have already begun putting my speech together.  Here the topic info:

Procedural to Object-Oriented: The Benefits of Using Object-Oriented PHP

Learn the power of object-oriented programming in PHP5 and the many benefits it offers over the more traditional PHP procedural programming style.  This session will include a light introduction to object-oriented concepts and will provide real-world concrete examples of the benefits it can offer you and the PHP projects you work on.

I will be speaking on October 9th at 2:30pm, and the presentation will last for roughly 75 minutes (60 minutes to speak, and 15 minutes for Q&A).  That’s a good chunk of time to fill, but there’s a lot on this topic that will need to be covered.  If you’re thinking about getting into object-oriented PHP programing or would like to learn more about it, please attend.  I will try my best to make sure there is at least something that everyone can learn.

You can also view my page on the conference website to read a short biography and get more information on the event.  Hope to see at least a few friendly faces there!

P.S. – I plan on posting my presentation slides on this website after the event just in case anyone missed anything important or was unable to attend.

UPDATE: The conference is over, and I have posted the powerpoint slides in another post for those that are interested in the presentations I made.

Building a Better Woot! Checker: Comparison is Key

The famous “one item per day” e-commerce store Woot! periodically holds a “woot-off”, where multiple different items are sold in quick succession, each item appearing as soon as the previous one sells out completely. The quick succession of potentially interesting items selling for steep discounts has created a proliferation of scripts and programs called “Woot checkers”, and has even lead to the creation of an official list of Woot-off checkers. All of this because of the potential of missing out on the opportunity to buy something great and get a great deal on it.

Continue reading