public static function findByUri($uri, $findAll = false) { $c = new Criteria(); $c->add(PrefixPeer::URI, $uri); $c->addAscendingOrderByColumn(PrefixPeer::RANK); if ($findAll) { return PrefixPeer::doSelect($c); } else { return PrefixPeer::doSelectOne($c); } }
public function test_get_record_by_uri() { //$this->tester->haveInDatabase( "reg_prefix", [ 'uri' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 'rank' => '2', 'rdf' ] ); $this->specify( "that the record can be retrieved by uri", function () { verify( $this->PrefixPeer->findByUri( "http://www.w3.org/1999/02/22-rdf-syntax-ns#" )->getPrefix() )->equals( "rdf" ); } ); }
public function getRdfNamespaces($criteria = null, $con = null) { $con = Propel::getConnection(SchemaPeer::DATABASE_NAME); $id = $this->getId(); $rs = $con->executeQuery(<<<SQL SELECT DISTINCT reg_prefix.prefix, reg_prefix.uri FROM reg_schema_property, \treg_schema_property_element, \tprofile_property, \treg_prefix WHERE reg_schema_property_element.schema_property_id = reg_schema_property.id \t\t\t\tAND reg_schema_property.schema_id = {$id} \t\t\t\tAND reg_schema_property_element.deleted_at IS NULL \t\t\t\tAND profile_property_id = profile_property.id \t\t\t\tAND reg_prefix.uri = profile_property.namespce ORDER BY reg_prefix.prefix SQL ); //we have some defaults $results['dc'] = PrefixPeer::findByPrefix('dc')->getUri(); $results['foaf'] = PrefixPeer::findByPrefix('foaf')->getUri(); $results['rdf'] = PrefixPeer::findByPrefix('rdf')->getUri(); $results['skos'] = PrefixPeer::findByPrefix('skos')->getUri(); while ($rs->next()) { $results[$rs->getString('prefix')] = $rs->getString('uri'); } ksort($results); return $results; }
public function retrievePrefixes() { $prefixes = $this->schema->getPrefixes(); if ('schema' === $this->type) { $namespaces = \SchemaPropertyElementPeer::getNamespaceList($this->schema->getId()); } else { $namespaces = \VocabularyPeer::getNamespaceList($this->schema->getId()); } //check the retrieved namespaces for a match to existing prefixes foreach ($namespaces as $uri) { //if we find the uri in existing schema prefixes, move on if ($prefixes and array_search($uri, $prefixes) !== false) { continue; } //look for it in Prefixes table $namespacePrefix = \PrefixPeer::findByUri($uri); if ($namespacePrefix) { //add it to the prefix array $prefixes[ $namespacePrefix->getPrefix() ] = $uri; } //check it against the schema token elseif (trim($uri, "/#") == trim($this->schema->getUri(), "#/")) { $prefixes[ $this->schema->getToken() ] = $uri; } else { $prefixes[ ] = $uri; } } if (empty($prefixes)) { $prefixes = $this->getDefaultPrefix(); } return $prefixes; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(PrefixPeer::PREFIX, $pks, Criteria::IN); $objs = PrefixPeer::doSelect($criteria, $con); } return $objs; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PrefixPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setPrefix($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUri($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setRank($arr[$keys[2]]); } }