本文整理匯總了PHP中Doctrine\DBAL\Types\Type::convertToPHPValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Type::convertToPHPValue方法的具體用法?PHP Type::convertToPHPValue怎麽用?PHP Type::convertToPHPValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Types\Type
的用法示例。
在下文中一共展示了Type::convertToPHPValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testArray
public function testArray()
{
$photo = new Photo();
$photo->setNom('wohoo');
$serialized = $this->type->convertToDatabaseValue([$photo], $this->plateform);
$unserialized = $this->type->convertToPHPValue($serialized, $this->plateform);
$this->assertInstanceOf(Photo::class, $unserialized[0]);
/** @var Photo $var */
$var = $unserialized[0];
$this->assertEquals('wohoo', $var->getNom());
}
示例2: convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
try {
return parent::convertToPHPValue($value, $platform);
} catch (ConversionException $e) {
$val = \DateTime::createFromFormat('Y-m-d H:i:s.uO', $value);
if (!$val) {
throw ConversionException::conversionFailedFormat($value, $this->getName(), 'Y-m-d H:i:s.uO');
}
return $val;
}
}
示例3: testConversionToPHP
/**
* @dataProvider sqlValueProvider
*/
public function testConversionToPHP($sql, $expected)
{
$value = $this->type->convertToPHPValue($sql, $this->platform);
$this->assertEquals($expected, $value);
}
示例4: testReturnValueIfUuidForPHPValue
public function testReturnValueIfUuidForPHPValue()
{
$uuid = Uuid::uuid4();
$this->assertSame($uuid, $this->type->convertToPHPValue($uuid, $this->platform));
}
示例5: value
private function value(EntityManager $em, Type $type, $value)
{
$platform = $em->getConnection()->getDatabasePlatform();
switch ($type->getName()) {
case Type::BOOLEAN:
return $type->convertToPHPValue($value, $platform);
// json supports boolean values
// json supports boolean values
default:
return $type->convertToDatabaseValue($value, $platform);
}
}