codeigniter 1.7.0 bugs

Update: 1.7.1 fixes both bugs.

So I recently upgraded from codeigniter 1.6.3 to 1.7.0 for a project of mine and I noticed 2 bugs after I had upgraded.  Luckily, they both have simple, easy workarounds.  The first problem I noticed was that the default port for the mysqli driver is not being set correctly. This will cause an error while trying to connect to the database: “Unable to connect to your database server using the provided settings.”  The easy workaround for this is to supply a default port in your database settings file if you use mysqli.  Something like

$db['default']['port'] = "3306";

should do the trick (depending on what you call your db connections and what ports the db uses for connections.  Of course, if you’re not using the default 3306 port, you probably already have a line like this in your configuration).

The second bug I found is that using random ordering with ActiveRecord on a mysql or mysqli connection is broken.  The correct syntax should be something like


However, there seems to be a quote escaping error that will cause an error message to spit out: “Unknown column ‘ RAND() LIMIT 1′ in ‘order clause’”.  The quick hack to solve this (for mysql dbs) is to put the random ordering directly into the first parameter of the order_by() call, like so:


This is not ideal but it’ll get the job done.  If you’re using order by random in a lot of different calls, you may want to try to fix the bug yourself.

Be Sociable, Share!
This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>