/** * Lookup a entity based on it's 'primary key' or key column when passed a set. * This will always return a Container * @return Container */ public function findBySet(Set $keySet) { $dataTypes = $this->dataTypesGet(DataType::PRIMARY_KEYS); if (count($dataTypes) == 0) { throw new \EntityPrimar("No primary keys for this entity. Don't know what key(s) to lookup on. Sorry."); } $identifiers = array(); foreach ($dataTypes as $dataType) { $identifiers[] = $this->db->quoteIdent($dataType->name); } $keySet->sqlIdentifierSet(implode("||'" . Base::KEY_SEPARATOR . "'||", $identifiers)); // lookup data $query = new Query(sprintf("SELECT * FROM ONLY %s WHERE %s", $this->db->quoteIdent($this->__get('table')), '%keySet:%'), array('keySet' => $keySet)); $result = $this->db->query($query); $datas = $result->fetch(Result::FLATTEN_PREVENT); return $this->initByDatas($datas); }