Here's a question from Tony Rigden who emailed me over the Christmas break.
--
In the manual under datamodel casting there is this statement
"Properties defined in static $db are automatically casted to their
data-types."
However, I am finding in my data object that whenever I read a property,
it is always returned as a string
eg
class MyObj extends DataObject{
static $db = array('myflag' => 'Boolean');
....
}
Works ok in forms etc but when I go to access it's values in code
eg
$myObj = MyObj::get_by_id("MyObj", 1);
var_dump($myObj->myflag);
It always shows: string(1) "0" or string(1) "1" depending of the value
in the database
I would have thought the word "automatically" meant you do not need to
use the static $casting array if you do not want to change the type. Is
this correct or do I have to put in the $casting array as well,
matching up the types in the $db array.