/**
  * description
  *
  * @return return_type
  * @param  var_type $var
  */
 public static function retrieveByUri($uri)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $criteria = new Criteria(VocabularyPeer::DATABASE_NAME);
     $criteria->add(self::URI, $uri);
     $criteria->addOr(self::URI, $uri . "#");
     $criteria->addOr(self::URI, $uri . "/");
     $v = VocabularyPeer::doSelect($criteria, $con);
     return !empty($v) > 0 ? $v[0] : null;
 }
예제 #2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Agent has previously
  * been saved, it will retrieve related Vocabularys from storage.
  * If this Agent is new, it will return
  * an empty collection or the current collection, the criteria
  * is ignored on a new object.
  *
  * @param      Connection $con
  * @param      Criteria $criteria
  * @throws     PropelException
  */
 public function getVocabularys($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseVocabularyPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collVocabularys === null) {
         if ($this->isNew()) {
             $this->collVocabularys = array();
         } else {
             $criteria->add(VocabularyPeer::AGENT_ID, $this->getId());
             VocabularyPeer::addSelectColumns($criteria);
             $this->collVocabularys = VocabularyPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(VocabularyPeer::AGENT_ID, $this->getId());
             VocabularyPeer::addSelectColumns($criteria);
             if (!isset($this->lastVocabularyCriteria) || !$this->lastVocabularyCriteria->equals($criteria)) {
                 $this->collVocabularys = VocabularyPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastVocabularyCriteria = $criteria;
     return $this->collVocabularys;
 }
예제 #3
0
 * @subpackage batch
 * @version    $Id$
 */
define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'frontend');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', 1);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
// batch process here
//get the vocabularies
$foo = new VocabularyPeer();
$selectCriteria = new Criteria(VocabularyPeer::DATABASE_NAME);
$rs = $foo->doSelect($selectCriteria);
$vocabCount = $foo->doCount($selectCriteria);
$vocabCounter = 0;
//foreach vocabulary
/** @var Vocabulary $vocavulary **/
foreach ($rs as $vocabulary) {
    $vocabCounter++;
    //get the vocabulary registrar
    $userCriteria = new Criteria();
    $userCriteria->add(VocabularyHasUserPeer::IS_REGISTRAR_FOR, true);
    $users = $vocabulary->getVocabularyHasUsersJoinUser($userCriteria);
    if (count($users)) {
        /**  @var VocabularyHasUser $user  */
        $user = $users[0]->getUser();
        $userId = $user->getId();
    }
 /**
  * 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(VocabularyPeer::ID, $pks, Criteria::IN);
         $objs = VocabularyPeer::doSelect($criteria, $con);
     }
     return $objs;
 }