When I retrieve a record from the database which has a column of type "uniqueidentifier", Doctrine fills it with "null" rather than the unique id from the database.
Some research and testing has brought this down to a PDO/dblib driver issue. When directly querying via PDO, null is returned in place of the unique id.
For reference, http://trac.doctrine-project.org/ticket/1096, has a bit on this, however, it was updated 11 months ago with no comment for resolution.
A way around this, as mentioned at http://bugs.php.net/bug.php?id=24752&edit=1, is to cast the column as a char. However, it doesn't seem Doctrine exposes the native field type outside of generating models which makes it a bit hard to detect uniqueidentifier types and cast them internally when building the sql query.
Has anyone found a workaround for this?
I submitted a patch for this, fix is in PHP 5.3.7 and later. See this bug report for further info http://bugs.php.net/54167
As of PHP 5.3.7 it will return the uniqueidentifier as a string which will work fine with Doctrine 1 & 2.
In my case, I also needed to specify the tds version in freetds.conf to properly receive the uniqueidentifier value as a string. The tds version that worked for me (which is probably specific to the SQL server version I am communicating with) is "tds version = 7.0"