secret
Created

  • Download Gist
tinyint.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
<?php
 
namespace EB\Core\KernelBundle\Doctrine\DBAL\Types;
 
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
 
/**
* Tinyint data type for Doctrine DBAL
*/
class TinyIntType extends Type
{
/**
* @const string
*/
const TINYINT = 'tinyint';
 
/**
* {@inheritDoc}
*/
public function getName()
{
return self::TINYINT;
}
 
/**
* {@inheritDoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return 'TINY' . $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
}
 
/**
* {@inheritDoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return (null === $value) ? null : (int) $value;
}
 
/**
* {@inheritDoc}
*/
public function getBindingType()
{
return \PDO::PARAM_INT;
}
 
/**
* {@inheritDoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.