Example #1
0
 /**
  * Execute.
  * @param $databaseFilePath Database file path.
  * @param $target replace target string.
  * @param $replace replaced string.
  * @return void
  */
 public function execute($databaseFilePath, $target, $replace)
 {
     Database::load($databaseFilePath);
     $tables = Model::findAllTableStructure();
     foreach ($tables as $table) {
         $rows = Model::findAll($table);
         foreach ($rows as &$row) {
             if ($this->replaceIfHit($row, $target, $replace)) {
                 Model::updateRow($row, $table);
             }
         }
     }
 }
Example #2
0
 public function testUpdateRow()
 {
     Model::updateRow(['id' => 1, 'name' => 'stigma'], 'users');
     $rows = Model::findAll("users");
     $this->assertSame($rows, [['id' => '1', 'name' => 'stigma'], ['id' => '2', 'name' => 'bob'], ['id' => '3', 'name' => 'mikel'], ['id' => '4', 'name' => 'jon']]);
 }