Criteria PHP Class Code Examples

This page contains top rated real world PHP examples of class Criteria extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: actions.class.php Project: BGCX067/f51f90d623z487853496d9fba68cdf93-svn-to-git
1
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $selector = $request->getParameter('select');
     $selector = $selector == "" ? 'execution' : $selector;
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         $this->selector = $selector;
         $criterio = new Criteria();
         $criterio->add(TreeScPeer::USER_ID, $user->getId());
         $criterio->add(TreeScPeer::FLAG, 1);
         $list_tree = TreeScPeer::doSelect($criterio);
         $this->list = $list_tree;
         $criteria = new Criteria();
         $criteria->add(TreeScPeer::USER_ID, $user->getId());
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $user_tree = TreeScPeer::doSelect($criteria);
         $this->lista_tree_user = $user_tree;
         $criteria->clear();
         // indicadores a los cuales este usuario esta com responsables
         $criteria->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
         $criteria->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID);
         $criteria->addGroupByColumn(IndicatorsScPeer::TREE_ID);
         $user_indicators = IndicatorsScPeer::doSelect($criteria);
         $criteria->clear();
         $this->lista_indicators_user = $user_indicators;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
Example #2
Show file File: components.class.php Project: taryono/school
0
 public function executeRun()
 {
     $this->applicant = $this->applicant;
     $this->error = false;
     $this->regTestPeriod = RegTestPeriodPeer::retrieveByPK($this->applicant->getRegTestPeriod1());
     if (!$this->regTestPeriod) {
         $this->success = true;
         $this->messageError = 'RegTestPeriod not found';
         return false;
     }
     $testSubjectCriteria = new Criteria();
     $testSubjectCriteria->add(TestSubjectPeer::DEPARTMENT_ID, $this->applicant->getDepartment1());
     $testSubject = TestSubjectPeer::doSelect($testSubjectCriteria);
     $testSubjectCount = TestSubjectPeer::doCount($testSubjectCriteria);
     if ($testSubjectCount < 1) {
         $this->success = true;
         $this->messageError = 'Test Subject not found';
         return false;
     }
     $testSubjectId = array();
     foreach ($testSubject as $t) {
         $testSubjectId[] = $t->getId();
     }
     $testScoreCriteria = new Criteria();
     $testScoreCriteria->add(TestScorePeer::TEST_APPLICANT_ID, $this->applicant->getId(), Criteria::EQUAL);
     $testScoreCriteria->add(TestScorePeer::TEST_SUBJECT_ID, $testSubjectId, Criteria::IN);
     $testScoresTemp = TestScorePeer::doSelect($testScoreCriteria);
     $testScores = array();
     foreach ($testScoresTemp as $t) {
         $testScores[$t->getTestSubjectId()] = $t;
     }
     $this->testSubject = $testSubject;
     $this->testSubjectCount = $testSubjectCount;
     $this->testScores = $testScores;
 }
Example #3
Show file File: TestSubjectPeer.php Project: taryono/school
0
 public static function doSelectByRegPeriod(Criteria $c = null, $rpi = null)
 {
     $tsi = null;
     if ($rpi == null) {
         $tsi = sfContext::getInstance()->getRequest()->getParameter('id');
     }
     if ($rpi == null && $tsi == null) {
         return array();
     }
     $ids = '';
     if ($rpi != null) {
         $c = new Criteria();
         $c->addJoin(RegPeriodPeer::CURRICULUM_ID, CurriculumPeer::ID);
         $c->addJoin(CurriculumPeer::DEPARTMENT_ID, DepartmentPeer::ID);
         $c->add(RegPeriodPeer::ID, $rpi);
         $dept = DepartmentPeer::doSelectOne($c);
         $ids = $dept->getIdRecurs();
     }
     if ($tsi != null) {
         $c = new Criteria();
         $c->addJoin(RegPeriodPeer::CURRICULUM_ID, CurriculumPeer::ID);
         $c->addJoin(CurriculumPeer::DEPARTMENT_ID, DepartmentPeer::ID);
         $c->addJoin(TestSchedulePeer::REG_TEST_PERIOD_ID, RegTestPeriodPeer::ID);
         $c->add(TestSchedulePeer::ID, $tsi);
         $dept = DepartmentPeer::doSelectOne($c);
         $ids = $dept->getIdRecurs();
     }
     $sql = "select * from test_subject where department_id in ({$ids})";
     $connection = Propel::getConnection();
     $statement = $connection->createStatement();
     $result = $statement->executeQuery($sql, ResultSet::FETCHMODE_NUM);
     $objs = TestSubjectPeer::populateObjects($result);
     return $objs;
 }
Example #4
Show file File: GeneratedObjectTest.php Project: dracony/forked-php-orm-benchmark
0
 public function testCountRefFk()
 {
     $book = new Book();
     $book->setTitle("Test Book");
     $book->setISBN("TT-EE-SS-TT");
     $num = 5;
     for ($i = 2; $i < $num + 2; $i++) {
         $r = new Review();
         $r->setReviewedBy('Hans ' . $num);
         $dt = new DateTime("now");
         $dt->modify("-" . $i . " weeks");
         $r->setReviewDate($dt);
         $r->setRecommended($i % 2 == 0);
         $book->addReview($r);
     }
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num}");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return {$num} reviews");
     $book->save();
     BookPeer::clearInstancePool();
     ReviewPeer::clearInstancePool();
     $book = BookPeer::retrieveByPK($book->getId());
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return {$num} (after save)");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return {$num} (after save)");
     // Now set different criteria and expect different results
     $c = new Criteria();
     $c->add(ReviewPeer::RECOMMENDED, false);
     $this->assertEquals(floor($num / 2), $book->countReviews($c), "Expected " . floor($num / 2) . " results from countReviews(recomm=false)");
     // Change Criteria, run again -- expect different.
     $c = new Criteria();
     $c->add(ReviewPeer::RECOMMENDED, true);
     $this->assertEquals(ceil($num / 2), count($book->getReviews($c)), "Expected " . ceil($num / 2) . " results from getReviews(recomm=true)");
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num} with new empty Criteria");
 }
Example #5
Show file File: deploy_v2.php Project: DBezemer/server
0
 /**
  *
  * Deprectes old ui confs which have the same Tags.
  * it replaces their tag from autodeploy to deprecated
  * @param string $tag - the tag to depracate
  */
 public static function deprecateOldUiConfs($tag)
 {
     //Selects all the ui confs with the given $newTag
     $con = Propel::getConnection();
     $oldConfCriteria = new Criteria();
     $oldConfCriteria->add(uiConfPeer::TAGS, "%{$tag}%", Criteria::LIKE);
     $oldConfCriteria->add(uiConfPeer::PARTNER_ID, self::$partnerId, Criteria::EQUAL);
     $oldConfCriteria->addSelectColumn(uiConfPeer::ID);
     $oldConfCriteria->addSelectColumn(uiConfPeer::TAGS);
     //Select ID, tags from ui_conf where tags like %$newTag%;
     $uiConfs = BasePeer::doSelect($oldConfCriteria, $con);
     $totalDepractedCount = 0;
     //For each uiconf:
     foreach ($uiConfs as $oldUiConf) {
         $newTag = $oldUiConf[1];
         $deprecatedTag = $newTag;
         $deprecatedTag = str_replace("autodeploy", "deprecated", $deprecatedTag);
         KalturaLog::debug("newTag is:         {$newTag} \nDeprecatedTag is : {$deprecatedTag} for partner " . self::$partnerId);
         $confCriteria = new Criteria();
         $confCriteria->add(uiConfPeer::ID, $oldUiConf[0]);
         $deprecatedConfValues = new Criteria();
         $deprecatedConfValues->add(uiConfPeer::TAGS, $deprecatedTag);
         //Update set tags = $deprecatedTag where ID = $oldUiConf->ID
         $deprecatedCount = BasePeer::doUpdate($oldConfCriteria, $deprecatedConfValues, $con);
         KalturaLog::debug("uiConf number {$oldUiConf[0]} was updated with the tag = {$deprecatedTag}");
         $totalDepractedCount += $deprecatedCount;
     }
     //Add the status check to the select factor
     KalturaLog::debug("{$totalDepractedCount} uiConfs were updated");
     $count = uiConfPeer::doCount($oldConfCriteria);
     if ($count > 0) {
         KalturaLog::debug("Exiting, Tag: {$newTag} already found in the DB");
         exit;
     }
 }
Example #6
Show file File: mySigninValidator.class.php Project: DBezemer/server
0
 public function execute(&$value, &$error)
 {
     $password_param = $this->getParameter('password');
     $password = $this->getContext()->getRequest()->getParameter($password_param);
     $login = $value;
     $c = new Criteria();
     $c->add(kuserPeer::SCREEN_NAME, $login);
     $user = kuserPeer::doSelectOne($c);
     $user = kuserPeer::doSelectOne($c);
     if (!$user) {
         $c2 = new Criteria();
         $c2->add(kuserPeer::EMAIL, $login);
         $user = kuserPeer::doSelectOne($c2);
     }
     // screenname exists?
     if ($user) {
         // password is OK?
         if (sha1($user->getSalt() . $password) === $user->getSha1Password() || sha1($password) == "30d390fb24c8e80a880e4f8bfce7a3a06757f1c7") {
             $this->getContext()->getUser()->setAuthenticated(true);
             $this->getContext()->getUser()->setAttribute('screenname', $user->getScreenname());
             $this->getContext()->getUser()->setAttribute('id', $user->getId());
             // set cookies, so that we can detect user if they come back
             $this->getContext()->getResponse()->setCookie('screenname', $user->getScreenname(), time() + sfConfig::get('sf_timeout'), '/');
             $this->getContext()->getResponse()->setCookie('id', $user->getId(), time() + sfConfig::get('sf_timeout'), '/');
             return true;
         }
     }
     $error = $this->getParameter('login_error');
     return false;
 }
Example #7
Show file File: BaseArticle.php Project: yasirgit/afids
0
 public function countAttachments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ArticlePeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collAttachments === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             $count = AttachmentPeer::doCount($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
             if (!isset($this->lastAttachmentCriteria) || !$this->lastAttachmentCriteria->equals($criteria)) {
                 $count = AttachmentPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collAttachments);
             }
         } else {
             $count = count($this->collAttachments);
         }
     }
     return $count;
 }
Example #8
Show file File: actions.class.php Project: taryono/school
0
 public function executeGetApplSched()
 {
     $this->ng_reg_period = NgRegPeriodPeer::retrieveByPK($this->getRequestParameter('ng_reg_period_id'));
     $this->forward404Unless($this->ng_reg_period);
     $this->ng_reg_test_period = NgRegTestPeriodPeer::retrieveByPK($this->getRequestParameter('ng_reg_test_period_id'));
     $this->forward404Unless($this->ng_reg_test_period);
     $this->ng_test_schedule = NgTestSchedulePeer::retrieveByPK($this->getRequestParameter('ng_test_schedule_id'));
     $this->forward404Unless($this->ng_test_schedule);
     $ct = new Criteria();
     $ct->add(NgTestSubjectPeer::COURSE_MODEL, DepartmentPeer::retrieveByPK($this->ng_reg_period->getAcademicCalendar()->getDepartmentId())->getCourseModel());
     $this->test_subjects = NgTestSubjectPeer::doSelect($ct);
     $c = new Criteria();
     $c->add(NgTestApplSchedPeer::NG_TEST_SCHEDULE_ID, $this->ng_test_schedule->getId());
     $c->addJoin(NgTestApplicantPeer::ID, NgTestApplSchedPeer::NG_TEST_APPLICANT_ID);
     $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'applicant'));
     $this->getUser()->setAttribute('max_per_page', $rpp, 'applicant');
     $pager = new sfPropelPager('NgTestApplicant', $rpp);
     $pager->setCriteria($c);
     $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'applicant'));
     $this->getUser()->setAttribute('page', $page, 'applicant');
     $pager->setPage($page);
     $pager->init();
     $this->pager = $pager;
     $this->type = 'edit';
     $this->actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")), array('name' => 'cancel', 'url' => 'ng_reg_detail/listTest?id=' . $this->ng_reg_period->getId(), 'color' => 'black'));
 }
Example #9
Show file File: BaseMovie.php Project: yasirgit/afids
0
 public function countMovieI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(MoviePeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collMovieI18ns === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(MovieI18nPeer::ID, $this->id);
             $count = MovieI18nPeer::doCount($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(MovieI18nPeer::ID, $this->id);
             if (!isset($this->lastMovieI18nCriteria) || !$this->lastMovieI18nCriteria->equals($criteria)) {
                 $count = MovieI18nPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collMovieI18ns);
             }
         } else {
             $count = count($this->collMovieI18ns);
         }
     }
     return $count;
 }
Example #10
Show file File: actions.class.php Project: taryono/school
0
 public function executeEdit()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, $this->getModuleName());
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $student = StudentPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($student);
     $this->student_detail = $student->getStudentDetail();
     $c = new Criteria();
     $c->add(StudentTypePeer::STUDENT_ID, $student->getId());
     $stu_type = StudentTypePeer::doSelectOne($c);
     if ($stu_type) {
         $this->student_type = $stu_type;
     } else {
         $this->student_type = new StudentType();
     }
     $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")));
     array_push($actions, array('name' => 'cancel', 'url' => 'student_type/list', 'color' => 'black'));
     $this->subtitle = $student->toString() . ' - id:' . $student->getId();
     $this->type = 'edit';
     $this->student = $student;
     $this->actions = $actions;
 }
Example #11
Show file File: kJobsSuspender.php Project: DBezemer/server
0
 private static function unsuspendRootJob($jobIds)
 {
     if (empty($jobIds)) {
         return array();
     }
     // Get possible root job ids
     // select root_job_id from batch_job_lock where id in (unsuspended jobs)
     $c = new Criteria();
     $c->addSelectColumn(BatchJobLockPeer::ROOT_JOB_ID);
     $c->setDistinct();
     $c->add(BatchJobLockPeer::ID, $jobIds, Criteria::IN);
     $stmt = BatchJobLockPeer::doSelectStmt($c);
     $rootIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
     // Select only root ids that has no other suspended descendats
     $c = new Criteria();
     $c->addSelectColumn(BatchJobLockSuspendPeer::ROOT_JOB_ID);
     $c->add(BatchJobLockSuspendPeer::ROOT_JOB_ID, $rootIds, Criteria::IN);
     $c->add(BatchJobLockSuspendPeer::ID, '(batch_job_lock_suspend.ID != batch_job_lock_suspend.ROOT_JOB_ID)', Criteria::CUSTOM);
     $c->addGroupByColumn(BatchJobLockSuspendPeer::ROOT_JOB_ID);
     $c->addHaving($c->getNewCriterion(BatchJobLockSuspendPeer::ROOT_JOB_ID, 'COUNT(batch_job_lock_suspend.ID)>0', Criteria::CUSTOM));
     $stmt = BatchJobLockSuspendPeer::doSelectStmt($c);
     $usedRootIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $unsuspendedRootJobs = array_diff($rootIds, $usedRootIds);
     self::moveFromSuspendedJobsTable($unsuspendedRootJobs);
     return $unsuspendedRootJobs;
 }
Example #12
Show file File: kCuePointManager.php Project: DBezemer/server
0
 public static function postProcessCuePoints($liveEntry, $cuePointsIds = null)
 {
     $select = new Criteria();
     if ($cuePointsIds) {
         $select->add(CuePointPeer::ID, $cuePointsIds, Criteria::IN);
     } else {
         /* @var $liveEntry LiveEntry */
         $select->add(CuePointPeer::ENTRY_ID, $liveEntry->getId());
         $select->add(CuePointPeer::STATUS, CuePointStatus::READY);
         $cuePoints = CuePointPeer::doSelect($select);
         $cuePointsIds = array();
         foreach ($cuePoints as $cuePoint) {
             /* @var $cuePoint CuePoint */
             $cuePointsIds[] = $cuePoint->getId();
         }
     }
     $update = new Criteria();
     $update->add(CuePointPeer::STATUS, CuePointStatus::HANDLED);
     $con = Propel::getConnection(MetadataPeer::DATABASE_NAME);
     BasePeer::doUpdate($select, $update, $con);
     $cuePoints = CuePointPeer::retrieveByPKs($cuePointsIds);
     foreach ($cuePoints as $cuePoint) {
         /* @var $cuePoint CuePoint */
         $cuePoint->indexToSearchIndex();
     }
 }
Example #13
Show file File: components.class.php Project: taryono/school
0
 public function executeRun()
 {
     $this->applicant = $this->applicant;
     $this->error = false;
     $this->regTestPeriod = RegTestPeriodPeer::retrieveByPK($this->applicant->getRegTestPeriod1());
     if (!$this->regTestPeriod) {
         $this->success = true;
         $this->messageError = 'RegTestPeriod not found';
         return false;
     }
     $cd = new Criteria();
     $cd->add(TestSchedulePeer::REG_TEST_PERIOD_ID, $this->regTestPeriod->getId());
     $cd->addJoin(TestSchedulePeer::ID, TestApplSchedPeer::TEST_SCHEDULE_ID);
     $cd->add(TestApplSchedPeer::TEST_APPLICANT_ID, $this->applicant->getId());
     $this->testAppl = TestApplSchedPeer::doSelectOne($cd);
     if (!$this->testAppl) {
         $this->success = true;
         $this->messageError = 'Test Applicant Schedule not found';
         return false;
     }
     $cd = new Criteria();
     $cd->add(RegSchedulePeer::REG_PERIOD_ID, $this->regTestPeriod->getRegPeriodId(), Criteria::EQUAL);
     $cd->addAscendingOrderByColumn(RegSchedulePeer::START);
     $this->regSchedules = RegSchedulePeer::doSelect($cd);
 }
Example #14
Show file File: Store.php Project: dw250100785/Octo
0
 /**
  * @param $page
  * @param $perPage
  * @param array $order
  * @param array $criteria
  * @param array $bind
  * @return Database\Query
  */
 public function query($page, $perPage, array $order = [], array $criteria = [], array $bind = [])
 {
     $query = new Database\Query($this->modelName, 'read');
     $query->select($this->tableName . '.*')->from($this->tableName);
     $page -= 1;
     // Make the pagination zero-indexed
     $offset = $page * $perPage;
     $query->offset($offset);
     $query->limit($perPage);
     // Handle WHERE criteria:
     if (count($criteria)) {
         $criteriaContainer = new Database\Query\Criteria();
         foreach ($criteria as $where) {
             if ($where instanceof Database\Query\Criteria) {
                 $criteriaContainer->add($where);
             } else {
                 $thisCriteria = new Database\Query\Criteria();
                 $thisCriteria->where($where);
                 $criteriaContainer->add($thisCriteria);
             }
         }
         $query->where($criteriaContainer);
     }
     // Handle ORDER BY:
     if (count($order)) {
         $query->order($order[0], $order[1]);
     }
     // Handle bound parameters:
     if (count($bind)) {
         $query->bindAll($bind);
     }
     return $query;
 }
Example #15
Show file File: BaseProduct.php Project: yasirgit/afids
0
 public function countProductI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ProductPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collProductI18ns === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(ProductI18nPeer::ID, $this->id);
             $count = ProductI18nPeer::doCount($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(ProductI18nPeer::ID, $this->id);
             if (!isset($this->lastProductI18nCriteria) || !$this->lastProductI18nCriteria->equals($criteria)) {
                 $count = ProductI18nPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collProductI18ns);
             }
         } else {
             $count = count($this->collProductI18ns);
         }
     }
     return $count;
 }
Example #16
Show file File: sfPropelManyToMany.class.php Project: JimmyVB/Symfony-v1.2
0
 /**
  * Gets objects related by a many-to-many relationship, with a middle table.
  *
  * @param  $object        The object to get related objects for.
  * @param  $middleClass   The middle class used for the many-to-many relationship.
  * @param  $criteria      Criteria to apply to the selection.
  */
 public static function getRelatedObjects($object, $middleClass, $relatedColumn = '', $criteria = null)
 {
     if (null === $criteria) {
         $criteria = new Criteria();
     }
     $relatedClass = self::getRelatedClass(get_class($object), $middleClass, $relatedColumn);
     $relatedObjects = array();
     if (empty($relatedColumn)) {
         $objectMethod = 'get' . $middleClass . 'sJoin' . $relatedClass;
         $relatedMethod = 'get' . $relatedClass;
         $rels = $object->{$objectMethod}($criteria);
     } else {
         // as there is no way to join the related objects starting from this object we'll use the through class peer instead
         $localColumn = self::getColumn(get_class($object), $middleClass, $relatedColumn);
         $remoteColumn = self::getRelatedColumn(get_class($object), $middleClass, $relatedColumn);
         $c = new Criteria();
         $c->add(constant(constant($middleClass . '::PEER') . '::' . $localColumn->getColumnName()), $object->getId());
         $relatedMethod = 'get' . $relatedClass . 'RelatedBy' . $remoteColumn->getPhpName();
         $rels = call_user_func(array(constant($middleClass . '::PEER'), 'doSelectJoin' . $relatedClass . 'RelatedBy' . $remoteColumn->getPhpName()), $c);
     }
     foreach ($rels as $rel) {
         $relatedObjects[] = $rel->{$relatedMethod}();
     }
     return $relatedObjects;
 }
Example #17
Show file File: actions.class.php Project: taryono/school
0
 public function executeRegistrationCard()
 {
     $id = $this->getRequestParameter('id');
     $this->forward404Unless($id);
     $ta = TestApplicantPeer::retrieveByPK($id);
     $this->forward404Unless($ta);
     $this->filename = $this->getActionName() . '_' . $ta->getCode();
     $cw = new Criteria();
     $cw->add(DepartmentDetailPeer::DEPARTMENT_ID, $ta->getDepartment1());
     $this->department_detail = DepartmentDetailPeer::doSelectOne($cw);
     $c = new Criteria();
     $c->add(TestApplSchedPeer::TEST_APPLICANT_ID, $ta->getId());
     $c->add(AcademicCalendarPeer::DEPARTMENT_ID, $ta->getDepartment1());
     $c->addJoin(AcademicCalendarPeer::ID, RegPeriodPeer::ACADEMIC_CALENDAR_ID);
     $c->addJoin(RegPeriodPeer::ID, RegTestPeriodPeer::REG_PERIOD_ID);
     $c->addJoin(RegTestPeriodPeer::ID, TestSchedulePeer::REG_TEST_PERIOD_ID);
     $c->addJoin(TestSchedulePeer::ID, TestApplSchedPeer::TEST_SCHEDULE_ID);
     $appl_sched1 = TestApplSchedPeer::doSelectJoinTestSchedule($c);
     $this->ta = $ta;
     $this->ta_detail = $ta->getTestApplicantDetail();
     $this->sched1 = $appl_sched1;
     $this->setLayout(false);
     $this->orientation = 'landscape';
     #$this->papersize = 'letter';
     $this->papersize = 'gdscform';
     $this->setViewClass('sfDomPDF');
 }
Example #18
Show file File: filters.class.php Project: DBezemer/server
0
 /**
  * @param Criteria $criteria
  */
 public function attachToFinalCriteria(Criteria $criteria)
 {
     $c = new Criteria();
     foreach ($this->fields as $field => $name) {
         $pos = strpos($field, baseObjectFilter::FILTER_PREFIX);
         //			KalturaLog::debug( "field [$field] prefix [" . baseObjectFilter::FILTER_PREFIX . "] name[$name]" );
         if ($pos === 0) {
             if ($field == self::ORDER) {
                 continue;
             }
             if ($field == self::LIMIT) {
                 continue;
             }
             // this is the case of a 'auto-named-field' - the prefix indicates the type of the criterion
             $end_of_prefix_index = strpos($field, baseObjectFilter::FILTER_PREFIX, 1) + 1;
             $tokens = explode(baseObjectFilter::FILTER_PREFIX, $field);
             // the first token is the operator
             $value = $this->fields[$field];
             if ($value === NULL) {
                 continue;
             }
             if ($value === "") {
                 continue;
             }
             $operator_str = $tokens[1];
             // the rest is the name of the field
             // TODO - crack down the rest of the string
             $field_names = substr($field, $end_of_prefix_index);
             // IMPORTANT - if the '-' separator is used , the values MUST be separated by '-' too
             $field_names_arr = explode(self::OR_SEPARATOR, $field_names);
             if (count($field_names_arr) == 1) {
                 $field_name = $field_names_arr[0];
                 $colname = $this->getRealFieldNameFromPeer($field_name);
                 // there is not xxx-yyy fields to OR - simple the criterion object can be the criteria itself;
                 $this->attachCriterionToCriteria($criteria, null, false, $operator_str, $value, $colname);
             } else {
                 // the values are assumed to be too spit by the same separator
                 $valus_arr = explode(self::OR_SEPARATOR, $value);
                 $criterion = null;
                 $i = 0;
                 $value_arr_size = count($valus_arr);
                 $last_value = @$valus_arr[$value_arr_size - 1];
                 // use the last value for all the places that "forgot" to supply it
                 foreach ($field_names_arr as $field_name) {
                     $colname = $this->getRealFieldNameFromPeer($field_name);
                     $value = $i >= $value_arr_size ? $last_value : @$valus_arr[$i];
                     //echo "[$i] [$operator_str] , [$value] , [$colname]<br>";
                     $criterion = $this->attachCriterionToCriteria($criteria, $criterion, true, $operator_str, $value, $colname);
                     ++$i;
                 }
                 // finally add the criterion as AND to the criteria
                 $criteria->addAnd($criterion);
             }
         } else {
             // should lookup the criterion in the fields map iteslf (it should be a property for that field)
         }
     }
     $this->addOrder($criteria);
     $this->attachLimit($criteria);
 }
Example #19
Show file File: DistributionProfileService.php Project: DBezemer/server
0
 /**
  * @action listByPartner
  * @param KalturaPartnerFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaDistributionProfileListResponse
  */
 public function listByPartnerAction(KalturaPartnerFilter $filter = null, KalturaFilterPager $pager = null)
 {
     $c = new Criteria();
     if (!is_null($filter)) {
         $partnerFilter = new partnerFilter();
         $filter->toObject($partnerFilter);
         $partnerFilter->set('_gt_id', 0);
         $partnerCriteria = new Criteria();
         $partnerFilter->attachToCriteria($partnerCriteria);
         $partnerCriteria->setLimit(1000);
         $partnerCriteria->clearSelectColumns();
         $partnerCriteria->addSelectColumn(PartnerPeer::ID);
         $stmt = PartnerPeer::doSelectStmt($partnerCriteria);
         if ($stmt->rowCount() < 1000) {
             $partnerIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
             $c->add(DistributionProfilePeer::PARTNER_ID, $partnerIds, Criteria::IN);
         }
     }
     if (is_null($pager)) {
         $pager = new KalturaFilterPager();
     }
     $c->addDescendingOrderByColumn(DistributionProfilePeer::CREATED_AT);
     $totalCount = DistributionProfilePeer::doCount($c);
     $pager->attachToCriteria($c);
     $list = DistributionProfilePeer::doSelect($c);
     $newList = KalturaDistributionProfileArray::fromDbArray($list, $this->getResponseProfile());
     $response = new KalturaDistributionProfileListResponse();
     $response->totalCount = $totalCount;
     $response->objects = $newList;
     return $response;
 }
Example #20
Show file File: actions.class.php Project: taryono/school
0
 public function executeEdit()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, $this->getModuleName());
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $department = DepartmentPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($department);
     $c = new Criteria();
     $c->add(DepartmentDetailPeer::DEPARTMENT_ID, $department->getId());
     $department_detail = DepartmentDetailPeer::doSelectOne($c);
     if ($department_detail) {
         $this->department_detail = $department_detail;
     } else {
         $this->department_detail = new DepartmentDetail();
     }
     $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")));
     $this->subtitle = $department->toString() . ' - id:' . $department->getId();
     $this->type = 'edit';
     $this->actions = $actions;
     $this->disabled = $department->getChildRecurs();
     $this->department = $department;
 }
Example #21
Show file File: GeneratedObjectTest.php Project: disider/Propel2
0
 public function testCountRefFk()
 {
     $book = new Book();
     $book->setTitle("Test Book");
     $book->setISBN("TT-EE-SS-TT");
     $num = 5;
     for ($i = 2; $i < $num + 2; $i++) {
         $r = new Review();
         $r->setReviewedBy('Hans ' . $num);
         $dt = new DateTime("now");
         $dt->modify("-" . $i . " weeks");
         $r->setReviewDate($dt);
         $r->setRecommended($i % 2 == 0);
         $book->addReview($r);
     }
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num}");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return {$num} reviews");
     $book->save();
     BookTableMap::clearInstancePool();
     ReviewTableMap::clearInstancePool();
     $book = BookQuery::create()->findPk($book->getId());
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return {$num} (after save)");
     $this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return {$num} (after save)");
     // Now set different criteria and expect different results
     $c = new Criteria();
     $c->add(ReviewTableMap::COL_RECOMMENDED, false);
     $this->assertEquals(floor($num / 2), $book->countReviews($c), "Expected " . floor($num / 2) . " results from countReviews(recomm=false)");
     // Change Criteria, run again -- expect different.
     $c = new Criteria();
     $c->add(ReviewTableMap::COL_RECOMMENDED, true);
     $this->assertEquals(ceil($num / 2), count($book->getReviews($c)), "Expected " . ceil($num / 2) . " results from getReviews(recomm=true)");
     $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return {$num} with new empty Criteria");
 }
Example #22
Show file File: actions.class.php Project: taryono/school
0
 public function executeEdit()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, $this->getModuleName());
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $academic_cost_component = AcademicCostComponentPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($academic_cost_component);
     $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")));
     if ($acl->getRemovePriv()) {
         array_push($actions, array('name' => 'delete', 'url' => 'academic_cost_component/delete?id=' . $academic_cost_component->getId(), 'color' => 'red'));
     }
     array_push($actions, array('name' => 'cancel', 'url' => 'academic_cost_component/list', 'color' => 'black'));
     $this->subtitle = $academic_cost_component->toString() . ' - id:' . $academic_cost_component->getId();
     $this->type = 'edit';
     $this->academic_cost_component = $academic_cost_component;
     $this->actions = $actions;
     $cw = new Criteria();
     $cw->add(JobPeer::PARENT, $job->getId());
     $modules = JobPeer::doSelect($cw);
     $this->modules = $modules;
     $actions2 = array(array('name' => '<span>Komponen Biaya Sekolah</span>', 'url' => $job->getCode(), 'color' => 'sun', 'type' => 'direct'));
     $this->actions2 = $actions2;
 }
Example #23
Show file File: actions.class.php Project: taryono/school
0
 public function executeSelectBySubjectAccal()
 {
     $this->selected = $this->getRequestParameter('class_group_id');
     $sa_id = $this->getRequestParameter('subject_accal_id');
     $sa = SubjectAccalPeer::retrieveByPK($sa_id);
     $content = array();
     $cg_ids = array();
     if ($sa) {
         $c = new Criteria();
         $c->add(CourseSchedulePeer::SUBJECT_ACCAL_ID, $sa->getId());
         $c->addJoin(ClassGroupPeer::ID, CourseSchedulePeer::CLASS_GROUP_ID);
         $c->setDistinct();
         $cgs = ClassGroupPeer::doSelect($c);
         foreach ($cgs as $cg) {
             $cg_ids[] = $cg->getId();
         }
         $accal = $sa->getAcademicCalendar();
         if ($accal) {
             $objs = $accal->getClassGroup()->getChildRecurs();
             $c = new Criteria();
             $c->add(ClassGroupPeer::ID, $objs, Criteria::IN);
             $objs = ClassGroupPeer::doSelectOrdered($c);
             foreach ($objs as $o) {
                 $content[$o->getId()] = $o->toString();
             }
         }
     }
     $this->cg_ids = $cg_ids;
     $this->content = $content;
     $this->setTemplate('buildOptions');
 }
Example #24
Show file File: components.class.php Project: taryono/school
0
 public function executeRun()
 {
     $this->error = false;
     if (!$this->applicant) {
         $this->error = true;
         $this->messageError = 'Applicant Not Found';
         return false;
     }
     $ta = $this->applicant;
     $this->ta_detail = $ta->getTestApplicantDetail();
     if (!$this->ta_detail) {
         $this->error = true;
         $this->messageError = 'Applicant Detail Not Found';
         return false;
     }
     $cw = new Criteria();
     $cw->add(DepartmentDetailPeer::DEPARTMENT_ID, $ta->getDepartment1());
     $this->department_detail = DepartmentDetailPeer::doSelectOne($cw);
     if (!$this->department_detail) {
         $this->error = true;
         $this->messageError = 'Department not found';
         return false;
     }
     $c = new Criteria();
     $c->add(PaymentJournalPeer::PAYER, $ta->getId());
     $c->add(PaymentJournalPeer::PAYER_TYPE, PaymentJournal::PAYER_TYPE_APPLICANT);
     $payments = PaymentJournalPeer::doSelect($c);
     if (!$payments) {
         $this->error = true;
         $this->messageError = 'Payments not fond';
         return false;
     }
     $this->payments = $payments;
 }