/** * Gets the order statement string for the relation of the provided has many field * @param string $fieldName Name of the has many field * @return null|string */ public function getRelationOrder($fieldName) { $field = $this->table->getField($fieldName); if (!$field instanceof HasManyField) { throw new ModelException($fieldName . ' is not a has many field'); } return $field->getRelationOrder(); }
/** * @expectedException zibo\library\orm\exception\ModelException */ public function testGetFieldThrowsExceptionWhenFieldNotFound() { $table = new ModelTable('table'); $table->getField('unexistant'); }
/** * Sets the the indexes to the model table * @param DOMElement $modelElement Element of the model * @param zibo\library\orm\definition\ModelTable $modelTable Model table which is being read * @return null */ protected function setIndexesFromElement(DOMElement $modelElement, ModelTable $modelTable) { $indexElements = $modelElement->getElementsByTagName(self::TAG_INDEX); foreach ($indexElements as $indexElement) { $indexFields = array(); $indexFieldElements = $indexElement->getElementsByTagName(self::TAG_INDEX_FIELD); foreach ($indexFieldElements as $indexFieldElement) { $fieldName = $indexFieldElement->getAttribute(self::ATTRIBUTE_NAME); $indexFields[$fieldName] = $modelTable->getField($fieldName); } $indexName = $indexElement->getAttribute(self::ATTRIBUTE_NAME); $index = new Index($indexName, $indexFields); $modelTable->setIndex($index); } }