i lost 3 hours on this thing, and still cant figure out whats wrong, iam trying to add a VARBINARY field type, and doctrine shows me that field as a option when generating new entity, but the problem is when i do php app/console doctrine:schema:update --force
then it gives me an error,
[DoctrineDBAL\DBALException]
An exception occured while executing 'CREATE TABLE Test (id INT AUTO_INCREMENT NOT NULL, name VARBINARY NOT NULL, PRIMARY KEY(id))
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;check the manual that corresponds to your MySQL server version for the right sytax to use near 'NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci EN' at line 1
this is my VARBINARY type class
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class VarBinaryType extends Type {
const VARBINARY = 'VARBINARY';
public function getName()
{
return self::VARBINARY;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) {
return $platform->getDoctrineTypeMapping('VARBINARY');
}
public function convertToDatabaseValue($value, AbstractPlatform $platform) {
return ($value === null)? null : base64_encode($value);
}
public function convertToPHPValue($value, AbstractPlatform $platform) {
return ($value === null)? null : base64_decode($value);
}
}
and i also did register it within boot function
$connection = $this->container->get('doctrine.orm.entity_manager')->getConnection();
if(!Type::hasType('VARBINARY'))
{
Type::addType('VARBINARY', 'Uapi\\CoreBundle\\System\\DBALType\\VarBinaryType');
$connection->getDatabasePlatform()->registerDoctrineTypeMapping('VARBINARY', 'VARBINARY');
}