1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 17:00:59 +01:00
phorge-phorge/resources/sql/autopatches/20160222.almanac.1.properties.php

29 lines
695 B
PHP
Raw Normal View History

<?php
$table = new AlmanacProperty();
$conn_w = $table->establishConnection('w');
// We're going to JSON-encode the value in each row: previously rows stored
// plain strings, but now they store JSON, so we need to update them.
foreach (new LiskMigrationIterator($table) as $property) {
$key = $property->getFieldName();
$current_row = queryfx_one(
$conn_w,
'SELECT fieldValue FROM %T WHERE id = %d',
$table->getTableName(),
$property->getID());
if (!$current_row) {
continue;
}
queryfx(
$conn_w,
'UPDATE %T SET fieldValue = %s WHERE id = %d',
$table->getTableName(),
phutil_json_encode($current_row['fieldValue']),
$property->getID());
}