/** * Return an EarthIT_DBC_SQLExpression that identifies the table. */ public function rcTableExpression(EarthIT_Schema_ResourceClass $rc) { $components = array(); foreach ($rc->getDbNamespacePath() as $ns) { $components[] = new EarthIT_DBC_SQLIdentifier($ns); } $components[] = new EarthIT_DBC_SQLIdentifier($this->dbObjectNamer->getTableName($rc)); return new EarthIT_DBC_SQLNamespacePath($components); }
protected static function findField($fieldRef, EarthIT_Schema_ResourceClass $rc, $fuzzyMatch = false) { if ($fuzzyMatch) { $fieldRef = EarthIT_Schema_WordUtil::minimize($fieldRef); foreach ($rc->getFields() as $fn => $f) { if ($fieldRef === EarthIT_Schema_WordUtil::minimize($fn)) { return $f; } } return null; } else { return $rc->getField($fieldRef); } }
public function updateItems(array $updatedFieldValues, EarthIT_Schema_ResourceClass $rc, EarthIT_Storage_ItemFilter $filter, array $options = array()) { $rcName = $rc->getName(); $matchedKeys = array(); if (isset($this->items[$rcName])) { foreach ($this->items[$rcName] as $k => $item) { if ($filter->matches($item)) { $matchedKeys[] = $k; } } } $updated = array(); foreach ($matchedKeys as $k) { $item = $this->items[$rcName][$k]; $item = $updatedFieldValues + $item; $id = EarthIT_Storage_Util::itemId($item, $rc); if ($id !== null and $id !== $k) { // TODO: Look at options to determine if updating is allowed // to overwrite other items unset($this->items[$rcName][$k]); $this->items[$rcName][$id] = $item; $k = $id; } $updated[$k] = $item; } return $updated; }
public static function storableFields(EarthIT_Schema_ResourceClass $rc) { return self::fieldsWithProperty($rc->getFields(), EarthIT_Storage_NS::HAS_A_DATABASE_COLUMN, true, false); }