/** * Removes the provided row from the database. * * @since 1.21 * * @param IORMRow $row * @param string|null $functionName * * @return boolean Success indicator */ public function removeRow(IORMRow $row, $functionName = null) { $success = $this->delete(array('id' => $row->getId()), is_null($functionName) ? __METHOD__ : $functionName); // DatabaseBase::delete does not always return true for success as documented... return $success !== false; }
/** * @dataProvider instanceProvider */ public function testSetFields(IORMRow $item) { $originalValues = $item->getFields(); $item->setFields(array(), false); foreach ($item->getTable()->getFields() as $name => $type) { $originalHas = array_key_exists($name, $originalValues); $newHas = $item->hasField($name); $this->assertEquals($originalHas, $newHas); if ($originalHas && $newHas) { $this->assertEquals($originalValues[$name], $item->getField($name)); } } $mockFields = $this->getMockFields(); $item->setFields($mockFields, false); $this->assertFieldValues($originalValues, $item); $item->setFields($mockFields, true); $this->assertFieldValues($mockFields, $item); }
/** * Formats a row to it's desired output format. * * @since 1.21 * * @param IORMRow $result * @param array $params * * @return mixed */ protected function formatRow(IORMRow $result, array $params) { return $result->toArray($params['props']); }
/** * Return if any fields got changed. * * @since 1.20 * * @param IORMRow $object * @param boolean|array $excludeSummaryFields * When set to true, summary field changes are ignored. * Can also be an array of fields to ignore. * * @return boolean */ protected function fieldsChanged(IORMRow $object, $excludeSummaryFields = false) { $exclusionFields = array(); if ($excludeSummaryFields !== false) { $exclusionFields = is_array($excludeSummaryFields) ? $excludeSummaryFields : $this->table->getSummaryFields(); } foreach ($this->fields as $name => $value) { $excluded = $excludeSummaryFields && in_array($name, $exclusionFields); if (!$excluded && $object->getField($name) !== $value) { return true; } } return false; }