Tuesday, February 26, 2008

PHP and NULL comparisons

Just a little gotcha in PHP and ms sql access:

If you fetch a row from my sql, and are trying to compare a field value to see if it is NULL, use the === operator. The == operator will trigger a type conversion inside PHP and make null == 0 returns true.

Reference: http://ca.php.net/manual/en/types.comparisons.php

Monday, February 25, 2008

A little bug in Rails?

We had to roll back a database migration on one of our development server today. Previously, we have changed column from "NOT NULL" to "NULL". This roll back is suppose to revert the column back to "NOT NULL".

It turns out that Rails did NOT revert the column, even if the migration states explicitly to do it. This is done on a MS SQL database using the freetds driver.