本文整理汇总了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);
}
}