Boolean Field Problem return string not integer
Posted 07 December 2012 - 12:53 AM
My table schema sql is:
CREATE TABLE `foo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`isbar` bool NOT NULL ,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
I have a Foo.php as:
class Foo extends CActiveRecord
public function rules()
I have a $fooObject which is an instance of Foo. let
I found that $json is a string like "0" or "1",but what I need is 0 ,1 ,false or true.
In a word, how can I let boolean property return integer or boolean?
Posted 07 December 2012 - 10:47 AM
I have tried tinyint(1),but nothing change.Actually,when I use bool in mysql,it creates a field of type tinyint(1) too. They are the same thing to mysql.
Posted 07 December 2012 - 03:20 PM
Sorry!I misunderstood your meaning.After some researches,I knew this is a php 'bug'.
Now my question become:how to detect a field is tinyint(1) type in active record?
what is the correct api for something like $fooObject->metadata->columns["isbar"]->fieldtype==="boolean"?