Convert MySQL BIT field to BOOLEAN using Doctrine

can someone tell me what is wrong with my code.

Using Doctrine 2 with PHP 5.3 MySQL 5.5

My YAML mapping is for a BIT field named IsDefault, which has a value of 1 or 0 if I want the value to be true or false in my application:

  IsDefault:
    type: boolean
    nullable: false

Generated Entity:

/**
* @var boolean $IsDefault
*/
private $IsDefault;


/**
 * Set IsDefault
 *
 * @param boolean $isDefault
 * @return Model
 */
public function setIsDefault($isDefault)
{
    $this->IsDefault = $isDefault;
    return $this;
}

/**
 * Get IsDefault
 *
 * @return boolean 
 */
public function getIsDefault()
{
    return $this->IsDefault;
}

Unfortunately, when accessing data in my application, each row returns IsDefault as TRUE. Does anyone know why?

+3
source share
1 answer

I have the same problem and I change Bit(1)to TINYINT(1)and it works well.

+2
source

All Articles