Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/ponder-mailkey-populate.php
| <?php | <?php | ||||
| echo "Populating Questions with mail keys...\n"; | echo pht('Populating Questions with mail keys...')."\n"; | ||||
| $table = new PonderQuestion(); | $table = new PonderQuestion(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| foreach (new LiskMigrationIterator($table) as $question) { | foreach (new LiskMigrationIterator($table) as $question) { | ||||
| $id = $question->getID(); | $id = $question->getID(); | ||||
| echo "Question {$id}: "; | echo pht('Question %d: ', $id); | ||||
| if (!$question->getMailKey()) { | if (!$question->getMailKey()) { | ||||
| queryfx( | queryfx( | ||||
| $question->establishConnection('w'), | $question->establishConnection('w'), | ||||
| 'UPDATE %T SET mailKey = %s WHERE id = %d', | 'UPDATE %T SET mailKey = %s WHERE id = %d', | ||||
| $question->getTableName(), | $question->getTableName(), | ||||
| Filesystem::readRandomCharacters(20), | Filesystem::readRandomCharacters(20), | ||||
| $id); | $id); | ||||
| echo "Generated Key\n"; | echo pht('Generated Key')."\n"; | ||||
| } else { | } else { | ||||
| echo "-\n"; | echo "-\n"; | ||||
| } | } | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||