当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Collection::create方法代码示例

本文整理汇总了PHP中Doctrine_Collection::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Collection::create方法的具体用法?PHP Doctrine_Collection::create怎么用?PHP Doctrine_Collection::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Collection的用法示例。


在下文中一共展示了Doctrine_Collection::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchRelatedFor

 /**
  * fetchRelatedFor
  *
  * fetches a component related to given record
  *
  * @param Doctrine_Record $record
  * @return Doctrine_Record|Doctrine_Collection
  */
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = array();
     $localTable = $record->getTable();
     foreach ((array) $this->definition['local'] as $local) {
         $value = $record->get($localTable->getFieldName($local));
         if (isset($value)) {
             $id[] = $value;
         }
     }
     if ($this->isOneToOne()) {
         if (!$record->exists() || empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
             $related = $this->getTable()->create();
         } else {
             $dql = 'FROM ' . $this->getTable()->getComponentName() . ' WHERE ' . $this->getCondition();
             $coll = $this->getTable()->getConnection()->query($dql, $id);
             $related = $coll[0];
         }
         $related->set($related->getTable()->getFieldName($this->definition['foreign']), $record, false);
     } else {
         if (!$record->exists() || empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
             $related = Doctrine_Collection::create($this->getTable());
         } else {
             $query = $this->getRelationDql(1);
             $related = $this->getTable()->getConnection()->query($query, $id);
         }
         $related->setReference($record, $this);
     }
     return $related;
 }
开发者ID:swk,项目名称:bluebox,代码行数:38,代码来源:ForeignKey.php

示例2: indexDirectory

 public function indexDirectory($dir)
 {
     if (!file_exists($dir)) {
         throw new Doctrine_Search_Indexer_Exception('Unknown directory ' . $dir);
     }
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
     $files = array();
     foreach ($it as $file) {
         $name = $file->getPathName();
         if (strpos($name, '.svn') === false) {
             $files[] = $name;
         }
     }
     $q = new Doctrine_Query();
     $q->delete()->from('Doctrine_File f')->where('f.url LIKE ?', array($dir . '%'))->execute();
     // clear the index
     $q = new Doctrine_Query();
     $q->delete()->from('Doctrine_File_Index i')->where('i.file_id = ?')->execute();
     $conn = Doctrine_Manager::connection();
     $coll = Doctrine_Collection::create('Doctrine_File');
     foreach ($files as $file) {
         $coll[]->url = $file;
     }
     $coll->save();
 }
开发者ID:swk,项目名称:bluebox,代码行数:25,代码来源:Indexer.php

示例3: fetchRelatedFor

 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->getIncremented();
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine_Core::ATTR_LOAD_REFERENCES)) {
         return Doctrine_Collection::create($this->getTable());
     } else {
         $q = new Doctrine_RawSql($this->getTable()->getConnection());
         $assocTable = $this->getAssociationFactory()->getTableName();
         $tableName = $record->getTable()->getTableName();
         $identifierColumnNames = $record->getTable()->getIdentifierColumnNames();
         $identifier = array_pop($identifierColumnNames);
         $sub = 'SELECT ' . $this->getForeignRefColumnName() . ' FROM ' . $assocTable . ' WHERE ' . $this->getLocalRefColumnName() . ' = ?';
         $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub . ')';
         $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getForeignRefColumnName();
         if ($this->definition['equal']) {
             $sub2 = 'SELECT ' . $this->getLocalRefColumnName() . ' FROM ' . $assocTable . ' WHERE ' . $this->getForeignRefColumnName() . ' = ?';
             $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub2 . ')';
             $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getLocalRefColumnName();
         }
         $q->select('{' . $tableName . '.*}, {' . $assocTable . '.*}')->from($tableName . ' INNER JOIN ' . $assocTable . ' ON ' . implode(' OR ', $joinCondition))->where(implode(' OR ', $condition))->orderBy($tableName . '.' . $identifier . ' ASC');
         if ($orderBy = $this->getOrderByStatement($tableName, true)) {
             $q->addOrderBy($orderBy);
         }
         $q->addComponent($tableName, $this->getClass());
         $path = $this->getClass() . '.' . $this->getAssociationFactory()->getComponentName();
         if ($this->definition['refClassRelationAlias']) {
             $path = $this->getClass() . '.' . $this->definition['refClassRelationAlias'];
         }
         $q->addComponent($assocTable, $path);
         $params = $this->definition['equal'] ? array($id, $id) : array($id);
         $res = $q->execute($params);
         return $res;
     }
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:34,代码来源:Nest.php

示例4: getApiVersions

 public function getApiVersions()
 {
     $versions = Doctrine_Collection::create('SymfonyApiVersion');
     $versions->setKeyColumn('id');
     foreach ($this['Releases'] as $release) {
         $versions->merge($release->getApiVersions());
     }
     return $versions;
 }
开发者ID:bshaffer,项目名称:Symplist,代码行数:9,代码来源:SymfonyPlugin.class.php

示例5: getCities

 public function getCities()
 {
     $mainCities = Doctrine_Collection::create('City');
     $user = sfContext::getInstance()->getUser();
     if (!$user->isAnonymous() && $user->getProfile()->getCity()) {
         $mainCities->add($user->getProfile()->getCity());
     }
     $mainCities->merge($this->createQuery()->where('weight >1')->orderBy('weight desc')->execute());
     return $mainCities;
 }
开发者ID:limitium,项目名称:uberlov,代码行数:10,代码来源:CityTable.class.php

示例6: initRelated

 public function initRelated(&$record, $name, $keyColumn = null)
 {
     if (!isset($this->_initializedRelations[$record->getOid()][$name])) {
         $relation = $record->getTable()->getRelation($name);
         $coll = Doctrine_Collection::create($relation->getTable()->getComponentName(), $keyColumn);
         $coll->setReference($record, $relation);
         $record[$name] = $coll;
         $this->_initializedRelations[$record->getOid()][$name] = true;
     }
     return true;
 }
开发者ID:hunde,项目名称:bsc,代码行数:11,代码来源:RecordDriver.php

示例7: filterOne

 public function filterOne($wheres)
 {
     $collection = Doctrine_Collection::create($this->_table->getOption('name'));
     foreach ($this->data as $record) {
         foreach ($wheres as $property => $value) {
             if ($record[$property] == $value) {
                 return $record;
             }
         }
     }
     return null;
 }
开发者ID:robertsergio,项目名称:Hadori-Demo,代码行数:12,代码来源:Doctrine_Collection_Extra.class.php

示例8: getFriends

 public function getFriends($memberId, $limit = null, $isRandom = false)
 {
     $collection = Doctrine_Collection::create('Member');
     $friendIds = $this->getFriendMemberIds($memberId);
     if ($isRandom) {
         shuffle($friendIds);
     }
     $limitedFriendIds = is_null($limit) ? $friendIds : array_slice($friendIds, 0, $limit);
     foreach ($limitedFriendIds as $friendId) {
         $collection[] = Doctrine::getTable('Member')->find($friendId);
     }
     return $collection;
 }
开发者ID:shotaatago,项目名称:OpenPNE3,代码行数:13,代码来源:MemberRelationshipTable.class.php

示例9: testGetAllowedWorkflowItems

 public function testGetAllowedWorkflowItems()
 {
     $flow = "Time";
     $state = "SUBMITTED";
     $role = "ESS USER";
     $fetchedRecord1 = TestDataService::fetchObject('WorkflowStateMachine', 10);
     $fetchedRecord2 = TestDataService::fetchObject('WorkflowStateMachine', 12);
     $expected = Doctrine_Collection::create('WorkflowStateMachine');
     $expected->add($fetchedRecord1);
     $expected->add($fetchedRecord2);
     $acessFlowStateMachineDaoMock = $this->getMock('AccessFlowStateMachineDao', array('getAllowedWorkflowItems'));
     $acessFlowStateMachineDaoMock->expects($this->once())->method('getAllowedWorkflowItems')->with($flow, $state, $role)->will($this->returnValue($expected));
     $this->accessFlowStateMachineService->setAccessFlowStateMachineDao($acessFlowStateMachineDaoMock);
     $results = $this->accessFlowStateMachineService->getAllowedWorkflowItems($flow, $state, $role);
     $this->assertEquals($expected, $results);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:16,代码来源:AccessFlowStateMachineServiceTest.php

示例10: configure

 public function configure()
 {
     /** @var sfGuardUser $object */
     $object = $this->getOption('object');
     /** @var TeamMember[]|Doctrine_Collection $links */
     $team = Doctrine_Collection::create('TeamMember');
     if (!$object->isNew()) {
         $team = $object->Team;
         foreach ($team as $i => $teamMember) {
             $this->embedForm($i, new TeamMemberForm($teamMember));
         }
     }
     for ($i = $team->count(); $i < 20; $i++) {
         $teamMember = new TeamMember();
         $teamMember->Manager = $object;
         $this->embedForm($i, new TeamMemberForm($teamMember));
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:18,代码来源:TeamForm.class.php

示例11: fetchRelatedFor

 /**
  * fetchRelatedFor
  *
  * fetches a component related to given record
  *
  * @param Doctrine_Record $record
  * @return Doctrine_Record|Doctrine_Collection
  */
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->getIncremented();
     if (empty($id) || ! $this->definition['table']->getAttribute(Doctrine_Core::ATTR_LOAD_REFERENCES)) {
         $coll = Doctrine_Collection::create($this->getTable());
     } else {
         $coll = $this->getTable()->getConnection()->query($this->getRelationDql(1), array($id));
     }
     $coll->setReference($record, $this);
     return $coll;
 }
开发者ID:nationalfield,项目名称:symfony,代码行数:19,代码来源:Association.php

示例12: populateRelated

 /**
  * Populate the relationship $name for all records in the passed collection
  *
  * @param string $name
  * @param Doctrine_Collection $coll
  * @return void
  */
 public function populateRelated($name, Doctrine_Collection $coll)
 {
     $rel = $this->_table->getRelation($name);
     $table = $rel->getTable();
     $foreign = $rel->getForeign();
     $local = $rel->getLocal();
     if ($rel instanceof Doctrine_Relation_LocalKey) {
         foreach ($this->data as $key => $record) {
             foreach ($coll as $k => $related) {
                 if ($related[$foreign] == $record[$local]) {
                     $this->data[$key]->setRelated($name, $related);
                 }
             }
         }
     } elseif ($rel instanceof Doctrine_Relation_ForeignKey) {
         foreach ($this->data as $key => $record) {
             if (!$record->exists()) {
                 continue;
             }
             $sub = Doctrine_Collection::create($table);
             foreach ($coll as $k => $related) {
                 if ($related[$foreign] == $record[$local]) {
                     $sub->add($related);
                     $coll->remove($k);
                 }
             }
             $this->data[$key]->setRelated($name, $sub);
         }
     } elseif ($rel instanceof Doctrine_Relation_Association) {
         $identifier = $this->_table->getIdentifier();
         $asf = $rel->getAssociationFactory();
         $name = $table->getComponentName();
         foreach ($this->data as $key => $record) {
             if (!$record->exists()) {
                 continue;
             }
             $sub = Doctrine_Collection::create($table);
             foreach ($coll as $k => $related) {
                 if ($related->get($local) == $record[$identifier]) {
                     $sub->add($related->get($name));
                 }
             }
             $this->data[$key]->setRelated($name, $sub);
         }
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:53,代码来源:Collection.php

示例13: makeOperationCollection

 /**
  * Создать коллекцию опреаций
  */
 public function makeOperationCollection($count, Account $account = null, array $props = array(), $save = true)
 {
     $coll = Doctrine_Collection::create('Operation');
     if (!$account) {
         $account = $this->makeAccount(null, array(), $save);
     }
     for ($i = 0; $i < (int) $count; $i++) {
         if (isset($props[$i])) {
             $itemProps = $props[$i];
         } else {
             $itemProps = array();
         }
         $coll->add($this->makeOperation($account, $itemProps, $save));
     }
     return $coll;
 }
开发者ID:ru-easyfinance,项目名称:EasyFinance,代码行数:19,代码来源:myTestObjectHelper.php

示例14: getInvitingMembers

 public function getInvitingMembers()
 {
     return Doctrine_Collection::create('Member');
 }
开发者ID:TadahiroKudo,项目名称:OpenPNE3,代码行数:4,代码来源:opAnonymousMember.class.php

示例15: getServiciosAccesibles

 function getServiciosAccesibles($entidad = 0)
 {
     foreach ($this->Servicios as $s) {
         $array_servicios[] = $s->codigo;
     }
     $servicios = Doctrine_Collection::create('Servicio');
     if ($this->interministerial) {
         if (!$entidad) {
             $servicios = Doctrine::getTable('Servicio')->findAll();
         } else {
             $servicios = Doctrine::getTable('Entidad')->find($entidad)->Servicios;
         }
     } else {
         if ($this->ministerial) {
             if (!$entidad) {
                 $servicios = Doctrine_Query::create()->from('Servicio s, s.Entidad e, e.Servicios serv')->whereIn('serv.codigo', $array_servicios)->execute();
             } else {
                 $servicios = Doctrine_Query::create()->from('Servicio s, s.Entidad e, e.Servicios serv')->whereIn('serv.codigo', $array_servicios)->andWhere('e.codigo = ?', $entidad)->execute();
             }
         } else {
             if (!$entidad) {
                 $servicios = $this->Servicios;
             } else {
                 $servicios = Doctrine_Query::create()->from('Servicio s, s.Entidad e')->whereIn('s.codigo', $array_servicios)->andWhere('e.codigo = ?', $entidad)->execute();
             }
         }
     }
     return $servicios;
 }
开发者ID:e-gob,项目名称:ChileAtiende,代码行数:29,代码来源:usuario_backend.php


注:本文中的Doctrine_Collection::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。