Exemplo n.º 1
0
 public function testUpdate()
 {
     $data = [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar'], ['id' => 3, 'name' => 'foobar']];
     // Update all
     $source = new ArrayDataSource($data);
     $selection = new UpdateSelectionBuilder($source);
     $selection->set('name', 'baz')->update();
     foreach ($source->getData() as $record) {
         $this->assertEquals('baz', $record['name']);
     }
     // Update using expression
     $selection = new UpdateSelectionBuilder($source);
     $selection->set('name', E::e('id'))->update();
     foreach ($source->getData() as $record) {
         $this->assertEquals($record['id'], $record['name']);
     }
 }
Exemplo n.º 2
0
 /**
  * Execute updates.
  *
  * @return int Number of updated records.
  */
 public function update()
 {
     $selection = new UpdateSelectionBuilder($this->getSource());
     return $selection->update();
 }