Просмотр файла database/upgrades/20200629223627_replace_chars_in_loads.php

Размер файла: 1.77Kb
<?php

use Phinx\Migration\AbstractMigration;

class ReplaceCharsInLoads extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up(): void
    {
        $this->execute("UPDATE loads SET name = replace(`name`, '&amp;', '&')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&quot;', '\"')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#039;', \"'\")");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#39;', \"'\")");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#36;', '$')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#92;', '\\\')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#124;', '|')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#94;', '^')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#96;', '`')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#37;', '%')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#58;', ':')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&#64;', '@')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&lt;', '<')");
        $this->execute("UPDATE loads SET name = replace(`name`, '&gt;', '>')");
    }

    /**
     * Migrate Down.
     */
    public function down(): void
    {
        $this->execute("UPDATE loads SET name = replace(`name`, '&', '&amp;')");
        $this->execute("UPDATE loads SET name = replace(`name`, '\"', '&quot;')");
        $this->execute("UPDATE loads SET name = replace(`name`, \"'\", '&#039;')");
        $this->execute("UPDATE loads SET name = replace(`name`, '<', '&lt;')");
        $this->execute("UPDATE loads SET name = replace(`name`, '>', '&gt;')");
    }
}