Ejemplo n.º 1
0
 /**
  * Method to test updateAll().
  *
  * @return void
  *
  * @covers Windwalker\DataMapper\AbstractDataMapper::updateAll
  */
 public function testUpdateAll()
 {
     $data = array('state' => 0);
     $this->instance->updateAll($data, array('id' => array(4, 5, 6)));
     $dataset = $this->loadToDataset('SELECT * FROM ww_flower WHERE id IN(4, 5, 6)');
     $this->assertEquals(array(0, 0, 0), $dataset->state);
 }
 /**
  * Using one data to update multiple rows, filter by where conditions.
  * Example:
  * `$mapper->updateAll(new Data(array('published' => 0)), array('date' => '2014-03-02'))`
  * Means we make every records which date is 2014-03-02 unpublished.
  *
  * @param mixed $data       The data we want to update to every rows.
  * @param mixed $conditions Where conditions, you can use array or Compare object.
  *                          Example:
  *                          - `array('id' => 5)` => id = 5
  *                          - `new GteCompare('id', 20)` => 'id >= 20'
  *                          - `new Compare('id', '%Flower%', 'LIKE')` => 'id LIKE "%Flower%"'
  *
  * @throws \InvalidArgumentException
  * @return  boolean
  */
 public function updateAll($data, $conditions = array())
 {
     $this->observers->update('onBeforeUpdateAll', array(&$data, &$conditions));
     $result = parent::updateAll($data, $conditions);
     $this->observers->update('onAfterUpdateAll', array(&$result));
     return $result;
 }