Archive for MySQL

Currency Conversion in CodeIgniter

Currency conversion for websites is one of those things where there’s lots of solutions, but all of them cost money.  I had to do this some time ago for an international procurement tool and, like most people, we had to use a paid solution.  But it got me thinking – currency data is just a series of numbers and must be published by someone, somewhere…

Read more

MySQL fulltext search wrongly return zero results

One of the best things about MySQL is the fulltext search, which uses some black magic to return a relevancy score.  It usually works a treat, but I’ve come up against a problem which I can’t find documented anywhere.  My problem was that, when performing a fulltext search, it was returning no results despite there clearly being some results it should display.  What was particularly confusing was that I’d got the query working on a table with lots of test data in, but couldn’t get it working on the table I was actually planning to use. Read more

CodeIgniter ActiveRecord Order by Field

Following on from my post about how to extend the CodeIgniter database library, I’ve had to to find a way of ordering database results by the values in an array.  This is particularly useful if you’ve got an enum field or have specified values in a particular field and then want to output it in a particularly order.  My magical order_by_field() method solves this problem.

Read more