public static function add($typeName, $values, $before = null)
    {
        $values = (array) $values;

        $db = static::getDb();
        if ($db->getTransaction()) {
            // It cannot add a value during a transaction.
            // Start new connection without transactions.
            $db = static::newConnection();
        }

        $query = 'ALTER TYPE ' . $db->quoteColumnName($typeName)
            . ' ADD VALUE IF NOT EXISTS ';

        $beforeQuery = $before !== null
            ? ' BEFORE ' . $db->quoteValue($before)
            : '';

        foreach ($values as $value) {
            $db->createCommand($query . $db->quoteValue($value) . $beforeQuery)->execute();
        }
    }
public static function add($typeName, $values, $before = null)
    {
        $values = (array) $values;

        $db = static::getDb();
        if ($db->getTransaction()) {
            // It cannot add a value during a transaction.
            // Start new connection without transactions.
            $db = static::newConnection();
        }

        $query = 'ALTER TYPE ' . $db->quoteColumnName($typeName)
            . ' ADD VALUE IF NOT EXISTS ';

        $beforeQuery = $before !== null
            ? ' BEFORE ' . $db->quoteValue($before)
            : '';

        foreach ($values as $value) {
            $db->createCommand($query . $db->quoteValue($value) . $beforeQuery)->execute();
        }
    }
public static function add ( $ typeName , $ values , $ before = null ) { $ values = ( array ) $ values ; $ db = static :: getDb ( ) ; if ( $ db -> getTransaction ( ) ) { // It cannot add a value during a transaction. // Start new connection without transactions. $ db = static :: newConnection ( ) ; } $ query = 'ALTER TYPE ' . $ db -> quoteColumnName ( $ typeName ) . ' ADD VALUE IF NOT EXISTS ' ; $ beforeQuery = $ before !== null ? ' BEFORE ' . $ db -> quoteValue ( $ before ) : '' ; foreach ( $ values as $ value ) { $ db -> createCommand ( $ query . $ db -> quoteValue ( $ value ) . $ beforeQuery ) -> execute ( ) ; } }
Add a value to an enum type

@param string $typeName name of the enum type
@param string|string[] $values new value or values for adding
@param string|null $before the value will be placed before
Add a value to an enum type