Вход Регистрация
Файл: vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/SimpleArrayType.php
Строк: 55
<?php

namespace DoctrineDBALTypes;

use 
DoctrineDBALPlatformsAbstractPlatform;

use function 
explode;
use function 
implode;
use function 
is_resource;
use function 
stream_get_contents;

/**
 * Array Type which can be used for simple values.
 *
 * Only use this type if you are sure that your values cannot contain a ",".
 */
class SimpleArrayType extends Type
{
    
/**
     * {@inheritdoc}
     */
    
public function getSQLDeclaration(array $columnAbstractPlatform $platform)
    {
        return 
$platform->getClobTypeDeclarationSQL($column);
    }

    
/**
     * {@inheritdoc}
     */
    
public function convertToDatabaseValue($valueAbstractPlatform $platform)
    {
        if (! 
$value) {
            return 
null;
        }

        return 
implode(','$value);
    }

    
/**
     * {@inheritdoc}
     */
    
public function convertToPHPValue($valueAbstractPlatform $platform)
    {
        if (
$value === null) {
            return [];
        }

        
$value is_resource($value) ? stream_get_contents($value) : $value;

        return 
explode(','$value);
    }

    
/**
     * {@inheritdoc}
     */
    
public function getName()
    {
        return 
Types::SIMPLE_ARRAY;
    }

    
/**
     * {@inheritdoc}
     */
    
public function requiresSQLCommentHint(AbstractPlatform $platform)
    {
        return 
true;
    }
}
Онлайн: 1
Реклама