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


PHP QueryBuilder::singleWordChoices方法代码示例

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


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

示例1: singleWords

 public function singleWords()
 {
     if ($this->request->is('post')) {
         if (!empty($this->request['data']['mainValue'])) {
             $this->set('mainValue', $this->request['data']['mainValue']);
             $documentModel = ClassRegistry::init('Document');
             $documentModel->recursive = 1;
             $documents = $documentModel->find('all');
             $this->set('documents', $documents);
             $languageModel = ClassRegistry::init('Language');
             $languageModel->recursive = 1;
             $languages = $languageModel->find('all');
             $this->set('languages', $languages);
             $this->set('documentFilter', array_key_exists('documentFilter', $this->request['data']) ? $this->request['data']['documentFilter'] : 0);
             if (isset($this->request['data']['documentIds'])) {
                 $documentIds = $this->request['data']['documentIds'];
             } else {
                 $documentIds = array();
             }
             $this->set('documentIds', $documentIds);
             $params = explode(',', $this->request['data']['mainValue']);
             $wordModel = ClassRegistry::init('Word');
             $wordModel->recursive = 2;
             $options = array('order' => 'case Word.split when 1 then concat(Word.stem, Word.suffix) else Word.text end', 'conditions' => array('Word.id IN (' . QueryBuilder::singleWordChoices($params) . ')'));
             if (!empty($documentIds)) {
                 array_push($options['conditions'], 'Word.id IN (' . QueryBuilder::singleWordDocuments($documentIds) . ')');
             } else {
                 array_push($options['conditions'], 'false');
             }
             $totalCount = $wordModel->find('count', $options);
             $this->set('word_count', $totalCount);
             $page = 0;
             if (!empty($this->request['data']['page'])) {
                 $page = $this->request['data']['page'];
             }
             $this->set('page', $page);
             $this->set('totalPages', (int) ($totalCount / $this->RESULTS_PER_PAGE) + 1);
             $options['limit'] = $this->RESULTS_PER_PAGE;
             $options['offset'] = $this->RESULTS_PER_PAGE * $page;
             $words = $wordModel->find('all', $options);
             $annotatedWords = array();
             $contexts = array();
             foreach ($words as $word) {
                 array_push($annotatedWords, new AnnotatedWord($word));
                 array_push($contexts, $documentModel->query(" select * from documents inner join languages on languages.id = documents.language_id inner join sentences on documents.id = sentences.document_id and sentences.id = " . $word['Word']['sentence_id'] . " inner join words on sentences.id = words.sentence_id order by words.position;"));
             }
             if (count($annotatedWords) != count($contexts)) {
                 die("annotatedWords is of different length than contexts");
             }
             $this->set('words', $annotatedWords);
             $this->set('contexts', $contexts);
             $wordAnnotationTypeModel = ClassRegistry::init('WordAnnotationType');
             $wordAnnotationTypeModel->recursive = 0;
             $this->set('wordAnnotationTypes', $wordAnnotationTypeModel->find('all'));
         } else {
             $this->Session->setFlash("Empty search query, add search criteria for all searched words.");
             return $this->redirect(array('action' => 'generator'));
         }
     }
 }
开发者ID:rjawor,项目名称:tagging,代码行数:60,代码来源:StatisticsController.php


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