芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/fmd/db/migrations/20200530103029_display_remote_links_migration.php
. */ use Phinx\Migration\AbstractMigration; /** * Class DisplayRemoteLinksMigration */ class DisplayRemoteLinksMigration extends AbstractMigration { /** @inheritDoc */ public function change() { $table = $this->table('display'); if (!$table->hasColumn('teamViewerSerial')) { $table ->addColumn('teamViewerSerial', 'string', ['limit' => 255, 'default' => null, 'null' => true]) ->addColumn('webkeySerial', 'string', ['limit' => 255, 'default' => null, 'null' => true]) ->save(); } // Go through all existing displays, and see if the teamviewerSerial or webkeySerial have been set in Display settings. foreach ($this->fetchAll('SELECT displayId, overrideConfig FROM `display`') as $row) { $displayId = (int)$row['displayId']; $overrideConfig = $row['overrideConfig']; if (!empty($overrideConfig)) { $teamViewerSerial = null; $webkeySerial = null; $overrideConfig = json_decode($overrideConfig, true); if (is_array($overrideConfig)) { foreach ($overrideConfig as $value) { if ($value['name'] === 'teamViewerSerial') { $teamViewerSerial = $value['value']; } else if ($value['name'] === 'webkeySerial') { $webkeySerial = $value['value']; } } } if ($teamViewerSerial !== null || $webkeySerial !== null) { $this->execute(sprintf('UPDATE `display` SET teamViewerSerial = %s, webkeySerial = %s WHERE displayId = %d', $teamViewerSerial === null ? 'NULL' : '\'' . $teamViewerSerial . '\'', $webkeySerial === null ? 'NULL' : '\'' . $webkeySerial . '\'', $displayId )); } } } } }