@@ 29-81 (lines=53) @@ | ||
26 | * |
|
27 | * @since 2.0 |
|
28 | */ |
|
29 | class ArrayType extends Type |
|
30 | { |
|
31 | /** |
|
32 | * {@inheritdoc} |
|
33 | */ |
|
34 | public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) |
|
35 | { |
|
36 | return $platform->getClobTypeDeclarationSQL($fieldDeclaration); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * {@inheritdoc} |
|
41 | */ |
|
42 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
43 | { |
|
44 | // @todo 3.0 - $value === null check to save real NULL in database |
|
45 | return serialize($value); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
52 | { |
|
53 | if ($value === null) { |
|
54 | return null; |
|
55 | } |
|
56 | ||
57 | $value = (is_resource($value)) ? stream_get_contents($value) : $value; |
|
58 | $val = unserialize($value); |
|
59 | if ($val === false && $value != 'b:0;') { |
|
60 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
61 | } |
|
62 | ||
63 | return $val; |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * {@inheritdoc} |
|
68 | */ |
|
69 | public function getName() |
|
70 | { |
|
71 | return Type::TARRAY; |
|
72 | } |
|
73 | ||
74 | /** |
|
75 | * {@inheritdoc} |
|
76 | */ |
|
77 | public function requiresSQLCommentHint(AbstractPlatform $platform) |
|
78 | { |
|
79 | return true; |
|
80 | } |
|
81 | } |
|
82 |
@@ 29-80 (lines=52) @@ | ||
26 | * |
|
27 | * @since 2.0 |
|
28 | */ |
|
29 | class ObjectType extends Type |
|
30 | { |
|
31 | /** |
|
32 | * {@inheritdoc} |
|
33 | */ |
|
34 | public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) |
|
35 | { |
|
36 | return $platform->getClobTypeDeclarationSQL($fieldDeclaration); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * {@inheritdoc} |
|
41 | */ |
|
42 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
43 | { |
|
44 | return serialize($value); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * {@inheritdoc} |
|
49 | */ |
|
50 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
51 | { |
|
52 | if ($value === null) { |
|
53 | return null; |
|
54 | } |
|
55 | ||
56 | $value = (is_resource($value)) ? stream_get_contents($value) : $value; |
|
57 | $val = unserialize($value); |
|
58 | if ($val === false && $value !== 'b:0;') { |
|
59 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
60 | } |
|
61 | ||
62 | return $val; |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * {@inheritdoc} |
|
67 | */ |
|
68 | public function getName() |
|
69 | { |
|
70 | return Type::OBJECT; |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * {@inheritdoc} |
|
75 | */ |
|
76 | public function requiresSQLCommentHint(AbstractPlatform $platform) |
|
77 | { |
|
78 | return true; |
|
79 | } |
|
80 | } |
|
81 |