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


PHP QueryObject::addAlias方法代码示例

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


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

示例1: search

 public function search()
 {
     $output = '';
     if (!$this->isJson()) {
         return $this->httpError(500, 'Content Type not allowed');
     }
     try {
         $search_params = json_decode($this->request->getBody(), true);
         $query = new QueryObject(new Consultant());
         $query->addAlias(QueryAlias::create('Company'));
         $query->addAndCondition(QueryCriteria::equal("Active", true));
         $location = @explode(',', @$search_params['location_term']);
         $name = @$search_params['name_term'];
         $service = @$search_params['service_term'];
         if (!empty($name)) {
             $query->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('CompanyService.Name', $name), QueryCriteria::like('CompanyService.Overview', $name), QueryCriteria::like('Company.Name', $name))));
         }
         if (!empty($service)) {
             $query->addAlias(QueryAlias::create('ConsultantServiceOfferedType'));
             $query->addAndCondition(QueryCriteria::like("ConsultantServiceOfferedType.Type", $service));
         }
         if (is_array($location) && !empty($location[0])) {
             $query->addAlias(QueryAlias::create('Office'));
             $query->addAndCondition(QueryCriteria::like("Office.City", $location[0]));
         }
         $countries = array_flip(Geoip::getCountryDropDown());
         if (is_array($location) && count($location) == 2) {
             $country = trim($location[1]);
             if (!empty($country) && array_key_exists($country, $countries)) {
                 $query->addAndCondition(QueryCriteria::like("Office.Country", $countries[$country]));
             }
         } else {
             if (is_array($location) && count($location) == 3) {
                 $state = trim($location[1]);
                 $country = trim($location[2]);
                 if (!empty($country) && array_key_exists($country, $countries)) {
                     $query->addAndCondition(QueryCriteria::like("Office.Country", $countries[$country]));
                 }
                 if (!empty($state)) {
                     $query->addAndCondition(QueryCriteria::like("Office.State", $state));
                 }
             }
         }
         list($list, $size) = $this->consultants_repository->getAll($query, 0, 1000);
         foreach ($list as $public_cloud) {
             $output .= $public_cloud->renderWith('ConsultantsDirectoryPage_CloudBox', array('ConsultantLink' => $this->Link()));
         }
     } catch (Exception $ex) {
         return $this->httpError(500, 'Server Error');
     }
     return empty($output) ? $this->httpError(404, '') : $output;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:52,代码来源:Consultants_Controller.php

示例2: getSteps

 /**
  * @return ISurveyStep[]
  */
 public function getSteps()
 {
     $query = new QueryObject(new SurveyStep());
     $query->addAlias(QueryAlias::create('Template'));
     $query->addOrder(QueryOrder::asc('Template.Order'));
     return new ArrayList(AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'Steps', $query)->toArray());
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:10,代码来源:Survey.php

示例3: getNominationsByNominee

 public function getNominationsByNominee($member_id, $offset = 0, $limit = 10)
 {
     $query = new QueryObject(new CandidateNomination());
     $query->addAlias(QueryAlias::create('Candidate'));
     $query->addAndCondition(QueryCriteria::equal('Member.ID', $member_id));
     return $this->getAll($query, $offset, $limit);
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:7,代码来源:SapphireCandidateNominationRepository.php

示例4: findByDupeAccount

 /**
  * @param string $dupe_account_email
  * @return IDupeMemberActionAccountRequest
  */
 public function findByDupeAccount($dupe_account_email)
 {
     $query = new QueryObject(new $this->entity_class());
     $query->addAlias(QueryAlias::create('DupeAccount'));
     $query->addAndCondition(QueryCriteria::equal('Member.Email', $dupe_account_email));
     return $this->getBy($query);
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:11,代码来源:SapphireDupeMemberActionAccountRequestRepository.php

示例5: search

 function search()
 {
     $output = '';
     if (!$this->isJson()) {
         return $this->httpError(500, 'Content Type not allowed');
     }
     try {
         $search_params = json_decode($this->request->getBody(), true);
         $query1 = new QueryObject(new Distribution());
         $query2 = new QueryObject(new Appliance());
         $query1->addAlias(QueryAlias::create('Company'));
         $query2->addAlias(QueryAlias::create('Company'));
         $name = @$search_params['name_term'];
         $service = @$search_params['service_term'];
         if (!empty($name)) {
             $query1->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('CompanyService.Name', $name), QueryCriteria::like('CompanyService.Overview', $name), QueryCriteria::like('Company.Name', $name))));
             $query2->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('CompanyService.Name', $name), QueryCriteria::like('CompanyService.Overview', $name), QueryCriteria::like('Company.Name', $name))));
         }
         if (!empty($service)) {
             $service = explode('-', $service);
             $query1->addAlias(QueryAlias::create('OpenStackImplementationApiCoverage')->addAlias(QueryAlias::create('OpenStackReleaseSupportedApiVersion')->addAlias(QueryAlias::create('OpenStackComponent'))));
             $query1->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('OpenStackComponent.Name', trim($service[0])), QueryCriteria::like('OpenStackComponent.CodeName', trim($service[1])))));
             $query2->addAlias(QueryAlias::create('OpenStackImplementationApiCoverage')->addAlias(QueryAlias::create('OpenStackReleaseSupportedApiVersion')->addAlias(QueryAlias::create('OpenStackComponent'))));
             $query2->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('OpenStackComponent.Name', trim($service[0])), QueryCriteria::like('OpenStackComponent.CodeName', trim($service[1])))));
         }
         $query1->addAndCondition(QueryCriteria::equal("Active", true));
         $query2->addAndCondition(QueryCriteria::equal("Active", true));
         list($list1, $size1) = $this->distribution_repository->getAll($query1, 0, 1000);
         list($list2, $size2) = $this->appliance_repository->getAll($query2, 0, 1000);
         $implementations = array_merge($list1, $list2);
         foreach ($implementations as $implementation) {
             $type = $implementation->getMarketPlace()->getName() == IDistribution::MarketPlaceType ? 'distribution' : 'appliance';
             $output .= $implementation->renderWith('DistributionsDirectoryPage_ImplementationBox', array('DistroLink' => $this->Link("distribution"), 'ApplianceLink' => $this->Link("appliance")));
         }
     } catch (Exception $ex) {
         return $this->httpError(500, 'Server Error');
     }
     return empty($output) ? $this->httpError(404, '') : $output;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:39,代码来源:Implementation_Controller.php

示例6: getConsultants

 public function getConsultants()
 {
     $product_name = trim(Convert::raw2sql($this->request->getVar('name')));
     $company_id = intval($this->request->getVar('company_id'));
     $sort = $this->request->getVar('sort');
     $query = new QueryObject(new CompanyService());
     $query_draft = new QueryObject(new CompanyServiceDraft());
     $query_draft->addAndCondition(QueryCriteria::equal('LiveServiceID', 0));
     //only drafts without live version
     $query->addAlias(QueryAlias::create('Company'));
     $query_draft->addAlias(QueryAlias::create('Company'));
     if (!empty($product_name)) {
         $query->addOrCondition(QueryCriteria::like('CompanyService.Name', $product_name));
         $query->addOrCondition(QueryCriteria::like('Company.Name', $product_name));
         $query_draft->addOrCondition(QueryCriteria::like('CompanyService.Name', $product_name));
         $query_draft->addOrCondition(QueryCriteria::like('Company.Name', $product_name));
     }
     if ($company_id > 0) {
         $query->addAndCondition(QueryCriteria::equal('Company.ID', $company_id));
         $query_draft->addAndCondition(QueryCriteria::equal('Company.ID', $company_id));
     }
     //set sorting
     if (!empty($sort)) {
         $dir = $this->getSortDir('consultants');
         $this->sortCompanyService($query, $sort, $dir);
         $this->sortCompanyService($query_draft, $sort, $dir);
     }
     //get consultants
     list($list1, $size1) = $this->consultant_repository->getAll($query, 0, 1000);
     list($list2, $size2) = $this->consultant_draft_repository->getAll($query_draft, 0, 1000);
     //return on view model
     return new ArrayList(array_merge($list1, $list2));
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:33,代码来源:MarketPlaceAdminPage.php

示例7: buildList

    /**
     * @param SS_HTTPRequest $request
     * @param string $template_class
     * @param string $ss_tpl_name
     * @return array
     */
    private function buildList(SS_HTTPRequest $request, $template_class = 'SurveyTemplate', $ss_tpl_name = 'SurveyBuilderListSurveys')
    {
        Requirements::javascript('themes/openstack/javascript/querystring.jquery.js');
        Requirements::javascript('survey_builder/js/survey.sangria.surveys.list.filter.js');
        $query_templates = new QueryObject(new SurveyTemplate());
        $query_templates->addAndCondition(QueryCriteria::equal('ClassName', $template_class));
        list($templates, $count) = $this->survey_template_repository->getAll($query_templates, 0, PHP_INT_MAX);
        $page = intval($request->getVar('page'));
        $survey_template_id = intval($request->getVar('survey_template_id'));
        $question_id = intval($request->getVar('question_id'));
        $question_value = Convert::raw2sql($request->getVar('question_value'));
        $question_value2 = Convert::raw2sql($request->getVar('question_value2'));
        $question_value = !empty($question_value) ? $question_value : $question_value2;
        $order = Convert::raw2sql($request->getVar('order'));
        $order_dir = Convert::raw2sql($request->getVar('dir'));
        if ($page === 0) {
            $page = 1;
        }
        $offset = ($page - 1) * self::SurveysPageSize;
        $sort_fields = ['id' => 'ID', 'created' => 'Created', 'updated' => 'LastEdited'];
        $query_surveys = new QueryObject(new Survey());
        $selected_template = $survey_template_id > 0 ? $this->survey_template_repository->getById($survey_template_id) : $templates[0];
        if ($survey_template_id === 0) {
            Controller::curr()->redirect($request->getURL(true) . '?survey_template_id=' . $selected_template->ID);
        }
        $query_surveys->addAndCondition(QueryCriteria::id('Survey.TemplateID', $selected_template->getIdentifier()))->addAndCondition(QueryCriteria::id('Survey.IsTest', 0));
        if ($question_id > 0 && !empty($question_value)) {
            // filter by question ...
            $query_surveys->addAlias(QueryAlias::create('Steps')->addAlias(QueryAlias::create('Answers')->addAlias(QueryAlias::create('Question'))));
            $query_surveys->addAndCondition(QueryCompoundCriteria::compoundAnd([QueryCriteria::id('SurveyQuestionTemplate.ID', $question_id), QueryCriteria::like('SurveyAnswer.Value', $question_value)]));
        }
        if (empty($order)) {
            $query_surveys->addOrder(QueryOrder::asc('ID'));
        } else {
            if ($order_dir === 'ASC') {
                $query_surveys->addOrder(QueryOrder::asc($sort_fields[$order]));
            } else {
                $query_surveys->addOrder(QueryOrder::desc($sort_fields[$order]));
            }
        }
        list($surveys, $count_surveys) = $this->survey_repository->getAll($query_surveys, $offset, self::SurveysPageSize);
        // build pager
        $pages = '';
        $max_page = intval(ceil($count_surveys / self::SurveysPageSize));
        for ($i = 1; $i < $max_page; $i++) {
            $pages .= sprintf("<li %s ><a href=\"%s?%s\">%s</a></li>", $page === $i ? "class=\"active\"" : "", $this->owner->Link($ss_tpl_name), $this->getPagerLink($i), $i);
        }
        $pager = <<<HTML
<nav>
    <ul class="pagination pagination-sm">
        {$pages}
    </ul>
</nav>
HTML;
        $result = ['Templates' => new ArrayList($templates), 'Surveys' => new ArrayList($surveys), 'Questions' => new ArrayList($selected_template->getAllFilterableQuestions()), 'Pager' => $pager];
        return $result;
    }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:63,代码来源:SangriaSurveyBuilderExtension.php


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