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


PHP Doctrine_Collection::add方法代码示例

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


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

示例1: getSampleDoctrineCollection

 /**
  *
  * @return Doctrine_Collection 
  */
 protected function getSampleDoctrineCollection()
 {
     $employee1 = new Employee();
     $employee2 = new Employee();
     $employee3 = new Employee();
     $employee1->fromArray(array('firstName' => 'John', 'lastName' => 'Smith'));
     $employee2->fromArray(array('firstName' => 'John', 'lastName' => 'Carter'));
     $employee3->fromArray(array('firstName' => 'John', 'lastName' => 'Jayapala'));
     $collection = new Doctrine_Collection('Employee');
     $collection->add($employee1);
     $collection->add($employee2);
     $collection->add($employee3);
     return $collection;
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:18,代码来源:WSUtilityDaoTest.php

示例2: executeImportSentences

 public function executeImportSentences(dmWebRequest $request)
 {
     $catalogue = $this->getObjectOrForward404($request);
     $form = new DmCatalogueImportForm();
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $file = $form->getValue('file');
         $override = $form->getValue('override');
         $dataFile = $file->getTempName();
         $table = dmDb::table('DmTransUnit');
         $existQuery = $table->createQuery('t')->select('t.id, t.source, t.target, t.created_at, t.updated_at')->where('t.dm_catalogue_id = ? AND t.source = ?');
         $catalogueId = $catalogue->get('id');
         $nbAdded = 0;
         $nbUpdated = 0;
         try {
             if (!is_array($data = sfYaml::load(file_get_contents($dataFile)))) {
                 $this->getUser()->logError($this->getI18n()->__('Could not load file: %file%', array('%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             }
         } catch (Exception $e) {
             $this->getUser()->logError($this->getI18n()->__('Unable to parse file: %file%', array('%file%' => $file->getOriginalName())));
             return $this->renderPartial('dmInterface/flash');
         }
         $addedTranslations = new Doctrine_Collection($table);
         $line = 0;
         foreach ($data as $source => $target) {
             ++$line;
             if (!is_string($source) || !is_string($target)) {
                 $this->getUser()->logError($this->getI18n()->__('Error line %line%: %file%', array('%line%' => $line, '%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             } else {
                 $existing = $existQuery->fetchOneArray(array($catalogueId, $source));
                 if (!empty($existing) && $existing['source'] === $source) {
                     if ($existing['target'] !== $target) {
                         if ($override || $existing['created_at'] === $existing['updated_at']) {
                             $table->createQuery()->update('DmTransUnit')->set('target', '?', array($target))->where('id = ?', $existing['id'])->execute();
                             ++$nbUpdated;
                         }
                     }
                 } elseif (empty($existing)) {
                     $addedTranslations->add(dmDb::create('DmTransUnit', array('dm_catalogue_id' => $catalogue->get('id'), 'source' => $source, 'target' => $target)));
                     ++$nbAdded;
                 }
             }
         }
         $addedTranslations->save();
         if ($nbAdded) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: added %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbAdded)));
         }
         if ($nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: updated %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbUpdated)));
         }
         if (!$nbAdded && !$nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: nothing to add and update', array('%catalogue%' => $catalogue->get('name'))));
         }
         return $this->renderText(url_for1($this->getRouteArrayForAction('index')));
     }
     $action = url_for1($this->getRouteArrayForAction('importSentences', $catalogue));
     return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
 }
开发者ID:theolymp,项目名称:diem,代码行数:60,代码来源:actions.class.php

示例3: reload

 public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Création de la collection d'objet EiProjectLang à ajouter
     $collection = new Doctrine_Collection("EiProjectLang");
     $items = $projets->getElementsByTagName("ei_project_langs");
     if ($items->length > 0) {
         //ya t-il des éléments à traiter?
         $ei_project_langs = $items->item(0)->getElementsByTagName("ei_project_lang");
         if ($ei_project_langs->length > 0) {
             foreach ($ei_project_langs as $ei_project_lang) {
                 $lang_id = $ei_project_lang->getAttribute("lang");
                 //recherche du profil en base
                 if ($lang_id != null && $project_ref != null && $project_id != null) {
                     $new_ei_project_lang = new EiProjectLang();
                     $new_ei_project_lang->setLang($lang_id);
                     $new_ei_project_lang->setProjectId($project_id);
                     $new_ei_project_lang->setProjectRef($project_ref);
                     $collection->add($new_ei_project_lang);
                 }
             }
             if ($collection->getFirst()) {
                 $collection->save($conn);
             }
             //Sauvegarde de la collection
             return 1;
         }
         return null;
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:32,代码来源:EiProjectLangTable.class.php

示例4: getSummary

 /**
  * Returns the SLA Summary (@see IcingaSLASummary) for this filter
  *
  * @param Doctrine_Connection $dbConnection
  * @param type $filter
  * @return Doctrine_Collection
  */
 public static function getSummary(Doctrine_Connection $dbConnection = null, $filter = null)
 {
     if ($dbConnection == null) {
         $dbConnection = AgaviContext::getInstance()->getDatabaseConnection("icinga");
     }
     $driver = $dbConnection->getDriverName();
     $stmt = null;
     switch (strtolower($driver)) {
         case 'pgsql':
             $stmt = self::getPgsqlSummaryQuery($dbConnection, $filter);
             break;
         case 'oracle':
         case 'icingaoracle':
             $stmt = self::getOracleSummaryQuery($dbConnection, $filter);
             break;
         case 'mysql':
             $stmt = self::getMySQLSummaryQuery($dbConnection, $filter);
             break;
         default:
             throw new AppKitDoctrineException("Invalid driver " . $driver);
     }
     $stmt->execute();
     $result = new Doctrine_Collection("IcingaSLASummary");
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $record = new IcingaSLASummary();
         foreach ($row as $key => $value) {
             $record->{strtolower($key)} = $value;
         }
         $result->add($record);
     }
     return $result;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:39,代码来源:IcingaSlahistoryTable.php

示例5: execute

 /**
  *
  * @param <type> $request
  */
 public function execute($request)
 {
     $this->setForm(new CopyActivityForm());
     $projectId = $request->getParameter('projectId');
     $this->form->bind($request->getParameter($this->form->getName()));
     $projectActivityList = $this->getProjectService()->getActivityListByProjectId($projectId);
     if ($this->form->isValid()) {
         $activityNameList = $request->getParameter('activityNames', array());
         $activities = new Doctrine_Collection('ProjectActivity');
         $isUnique = true;
         foreach ($activityNameList as $activityName) {
             foreach ($projectActivityList as $projectActivity) {
                 if (strtolower($activityName) == strtolower($projectActivity->getName())) {
                     $isUnique = false;
                     break;
                 }
             }
         }
         if ($isUnique) {
             foreach ($activityNameList as $activityName) {
                 $activity = new ProjectActivity();
                 $activity->setProjectId($projectId);
                 $activity->setName($activityName);
                 $activity->setIsDeleted(ProjectActivity::ACTIVE_PROJECT);
                 $activities->add($activity);
             }
             $activities->save();
             $this->getUser()->setFlash('templateMessageAct', array('success', __('Successfully Copied')));
         } else {
             $this->getUser()->setFlash('templateMessageAct', array('failure', __('Name Already Exists')));
         }
         $this->redirect('admin/saveProject?projectId=' . $projectId);
     }
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:38,代码来源:copyActivityAction.class.php

示例6: fetchOffsetsByToken

 /**
  *
  * @param PetitionApiToken $api_token
  * @return \Doctrine_Collection
  */
 public function fetchOffsetsByToken(PetitionApiToken $api_token)
 {
     $coll = new Doctrine_Collection('ApiTokenOffset', 'country');
     foreach ($this->createQuery('o')->where('o.petition_api_token_id = ?', $api_token->getId())->execute() as $offset) {
         $coll->add($offset);
     }
     return $coll;
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:13,代码来源:ApiTokenOffsetTable.class.php

示例7: reload

 public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Création de la collection d'objet EiVersionNotice à ajouter
     $collection = new Doctrine_Collection("EiVersionNotice");
     //Supression des versions de notice qui n'existent plus sur script
     $this->deleteNotFoundVersionNotice($conn);
     $items = $projets->getElementsByTagName("ei_version_notices");
     if ($items->length > 0) {
         //ya t-il des éléments à traiter?
         $ei_version_notices = $items->item(0)->getElementsByTagName("ei_version_notice");
         if ($ei_version_notices->length > 0) {
             foreach ($ei_version_notices as $ei_version_notice) {
                 $notice_id = $ei_version_notice->getAttribute("notice_id");
                 $notice_ref = $ei_version_notice->getAttribute("notice_ref");
                 $version_notice_id = $ei_version_notice->getAttribute("version_notice_id");
                 $lang = $ei_version_notice->getAttribute("lang");
                 //recherche du profil en base
                 if ($notice_id != null && $notice_ref != null && $version_notice_id != null && $lang != null) {
                     $q = Doctrine_Core::getTable('EiVersionNotice')->findOneByNoticeIdAndNoticeRefAndVersionNoticeIdAndLang($notice_id, $notice_ref, $version_notice_id, $lang);
                     if ($q && $q != null) {
                         //si l'element existe , on fait une mise à jour
                         $q->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue);
                         $q->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue);
                         $q->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue);
                         $q->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue);
                         $q->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $q->save($conn);
                     } else {
                         //l'élément n'existe pas encore, et dans ce cas on le crée
                         $new_ei_version_notice = new EiVersionNotice();
                         $new_ei_version_notice->setNoticeId($notice_id);
                         $new_ei_version_notice->setNoticeRef($notice_ref);
                         $new_ei_version_notice->setVersionNoticeId($version_notice_id);
                         $new_ei_version_notice->setLang($lang);
                         $new_ei_version_notice->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue);
                         $new_ei_version_notice->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue);
                         $new_ei_version_notice->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue);
                         $new_ei_version_notice->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue);
                         $new_ei_version_notice->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $collection->add($new_ei_version_notice);
                     }
                 }
             }
             if ($collection->getFirst()) {
                 $collection->save($conn);
             }
             //Sauvegarde de la collection
             return 1;
         }
         return null;
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:55,代码来源:EiVersionNoticeTable.class.php

示例8: _saveEmployeeWorkShift

 private function _saveEmployeeWorkShift($workShiftId, $empArray)
 {
     $empWorkShiftCollection = new Doctrine_Collection('EmployeeWorkShift');
     for ($i = 0; $i < sizeof($empArray); $i++) {
         $empWorkShift = new EmployeeWorkShift();
         $empWorkShift->setWorkShiftId($workShiftId);
         $empWorkShift->setEmpNumber($empArray[$i]);
         $empWorkShiftCollection->add($empWorkShift);
     }
     $this->getWorkShiftService()->saveEmployeeWorkShiftCollection($empWorkShiftCollection);
 }
开发者ID:THM068,项目名称:orangehrm,代码行数:11,代码来源:WorkShiftForm.php

示例9: getVotosAus

 public function getVotosAus()
 {
     $this->getCamara() == 'C.Diputados' ? $camara = 'D' : ($camara = 'S');
     $parlamentarios = Doctrine_Core::getTable('Parlamentario')->createQuery('p')->where('p.senador_diputado = ?', $camara)->andWhere('p.activo = ?', 1)->execute();
     $ausentes = new Doctrine_Collection('Parlamentario');
     foreach ($parlamentarios as $i => $parl) {
         if (Doctrine_Core::getTable('VotacionParlamentario')->find(array($this->getIdVotacion(), $parl->getIdParlamentario())) == null) {
             $ausentes->add($parl);
         }
     }
     return $ausentes;
 }
开发者ID:votainteligente,项目名称:legislativo,代码行数:12,代码来源:Votacion.class.php

示例10: executeDissociate

 public function executeDissociate(sfWebRequest $request)
 {
     $this->rfid_groupe = $this->getRoute()->getObject();
     $rfids = Doctrine_Core::getTable('Rfid')->findByGroupeId($this->rfid_groupe->getGuid());
     $collection = new Doctrine_Collection('Rfid');
     foreach ($rfids as $rfid) {
         $rfid->setGroupeId(null);
         $collection->add($rfid);
     }
     $collection->save();
     $this->redirect('@rfid_groupe');
 }
开发者ID:pmoutet,项目名称:navinum,代码行数:12,代码来源:actions.class.php

示例11: getAllCampaignExecutions

 /**
  * @param $campaign_id
  * @param $orders
  */
 public function getAllCampaignExecutions($campaign_id, $orders = array())
 {
     // Création de la requête SQL de récupération
     $sql = "SELECT * FROM ei_campaign_status_vw WHERE campaign_id = " . $campaign_id . " ORDER BY created_at DESC;";
     // Récupération des résultats.
     $resultats = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAll($sql);
     // Création de la collection.
     $collection = new Doctrine_Collection("EiCampaignExecution");
     foreach ($resultats as $resultat) {
         $collection->add($this->createObjectStatusFromArray($resultat));
     }
     return $collection;
 }
开发者ID:lendji4000,项目名称:compose,代码行数:17,代码来源:EiCampaignExecutionTable.class.php

示例12: updateObject

 public function updateObject($values = null)
 {
     $issues = new Doctrine_Collection('Issue');
     $values = $this->getChangedValues();
     foreach ($this->ids as $id) {
         $issue = Doctrine::getTable('Issue')->getForShow(array('id' => $id));
         $issue->takeSnapshot();
         $issue->fromArray($values);
         $issue->addActivityNote($this->getValue('body'));
         $issues->add($issue);
     }
     $this->object = $issues;
     return $issues;
 }
开发者ID:jackbravo,项目名称:amaranto,代码行数:14,代码来源:IssueBatchForm.class.php

示例13: updatePosition

 public function updatePosition($ids, $campaign_id)
 {
     if (!is_array($ids)) {
         return null;
     }
     //On reconstruit les relations de la table graph_has_graph
     $newStepTab = array();
     $ids = $ids[0];
     if (!is_array($ids)) {
         return null;
     }
     foreach ($ids as $i => $item) {
         if (array_key_exists($i + 1, $ids)) {
             $newStepTab[] = array($ids[$i], $ids[$i + 1]);
         }
     }
     //var_dump($newStepTab);
     if (!is_array($newStepTab)) {
         return null;
     }
     $conn = Doctrine_Manager::connection();
     try {
         $conn->beginTransaction();
         /*On vérifie qu'on est pas en accès concurrent */
         $nb = count(Doctrine_Core::getTable('EiCampaignGraph')->findByCampaignId($campaign_id));
         if ($nb != count($ids)) {
             throw new Exception('Concurrent Access. refresh page ...');
         }
         $conn->delete($this->getInstance(), array('campaign_id' => $campaign_id));
         $collection = new Doctrine_Collection($this->getInstance());
         foreach ($newStepTab as $item) {
             $newItem = new EiCampaignGraphHasGraph();
             $newItem->setParentId($item[0]);
             $newItem->setChildId($item[1]);
             $newItem->setCampaignId($campaign_id);
             $collection->add($newItem);
         }
         $collection->save($conn);
         $conn->commit();
         //  validation globale  de la création
         return 1;
     } catch (Exception $e) {
         $conn->rollback();
         //throw $e('An error occurred while trying to update nodes positions ');
         return -1;
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:47,代码来源:EiCampaignGraphHasGraphTable.class.php

示例14: reload

 public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Création de la collection d'objet View à ajouter
     $collection = new Doctrine_Collection("EiView");
     $items = $projets->getElementsByTagName("ei_views");
     if ($items->length > 0) {
         //ya t-il des éléments à traiter?
         $ei_views = $items->item(0)->getElementsByTagName("ei_view");
         if ($ei_views->length > 0) {
             foreach ($ei_views as $ei_view) {
                 $view_id = $ei_view->getAttribute("view_id");
                 $view_ref = $ei_view->getAttribute("view_ref");
                 //recherche du profil en base
                 if ($view_id != null && $view_ref != null) {
                     $q = Doctrine_Core::getTable('EiView')->findOneByViewIdAndViewRef($view_id, $view_ref);
                     if ($q && $q != null) {
                         //si l'element existe , on fait une mise à jour
                         $q->setDescription($ei_view->getElementsByTagName("description")->item(0)->nodeValue);
                         $q->setIsActive($ei_view->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $q->save($conn);
                     } else {
                         //l'élément n'existe pas encore, et dans ce cas on le crée
                         $new_ei_view = new EiView();
                         $new_ei_view->setViewId($view_id);
                         $new_ei_view->setViewRef($view_ref);
                         $new_ei_view->setDescription($ei_view->getElementsByTagName("description")->item(0)->nodeValue);
                         $new_ei_view->setIsActive($ei_view->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $new_ei_view->setProjectId($project_id);
                         $new_ei_view->setProjectRef($project_ref);
                         //                        $new_ei_view->save($conn);
                         $collection->add($new_ei_view);
                     }
                 }
             }
             if ($collection->getFirst()) {
                 $collection->save($conn);
             }
             //Sauvegarde de la collection
             return 1;
         }
         return null;
         //On a retrouvé aucun élément de ce type
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:47,代码来源:EiViewTable.class.php

示例15: testGetNonPredefinedUserRoles

 /**
  * @covers SystemUserService::getNonPredefinedUserRoles
  */
 public function testGetNonPredefinedUserRoles()
 {
     $userRoles = new Doctrine_Collection('UserRole');
     for ($i = 0; $i < 2; $i++) {
         $userRole = new UserRole();
         $userRole->setId($i + 1);
         $userRole->setName("test name" . $i + 1);
         $userRole->setIsAssignable(1);
         $userRole->setIsPredefined(0);
         $userRoles->add($userRole);
     }
     $dao = $this->getMock('SystemUserDao');
     $dao->expects($this->once())->method('getNonPredefinedUserRoles')->will($this->returnValue($userRoles));
     $this->systemUserService->setSystemUserDao($dao);
     $result = $this->systemUserService->getNonPredefinedUserRoles();
     $this->assertEquals($userRoles, $result);
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:20,代码来源:SystemUserServiceTest.php


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