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


PHP files::select方法代码示例

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


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

示例1: base

 public function base()
 {
     $submit = isset($_GET['submit']) ? true : false;
     $link = isset($_GET['link']) ? $_GET['link'] : false;
     $message = 'Add the link below';
     if ($submit && $link) {
         $link_explode = explode('/', $link);
         $file = new files($this->getDb());
         $added = $file->select('*', 'WHERE link="' . $link . '"');
         if (!isset($added[0]['id'])) {
             $file->insert(array('name' => urldecode($link_explode[count($link_explode) - 1]), 'approved' => 0, 'downloaded' => 0, 'created' => time(), 'link' => $link));
             $message = 'Successfully Added! You can add another link below';
         } else {
             $message = 'This link is already in the index. You can add another link below';
         }
     }
     $this->set('message', $message);
 }
开发者ID:sudhanshuraheja,项目名称:PDF-Search,代码行数:18,代码来源:addController.php

示例2: getFileId

 private function getFileId($file_name)
 {
     if ($file_name == '') {
         return;
     }
     $file = new files($this->getDb());
     $file_id = false;
     $files = $file->select('*', 'WHERE name="' . $file_name . '" OR name="' . $file_name . '.pdf" ');
     if (!isset($files[0]['id'])) {
         $id_array = $file->insert(array('name' => $file_name, 'approved' => 1, 'downloaded' => 1, 'created' => time()));
         $file_id = $id_array[0][1];
     } else {
         $file_id = $files[0]['id'];
     }
     return $file_id;
 }
开发者ID:sudhanshuraheja,项目名称:PDF-Search,代码行数:16,代码来源:processController.php

示例3: base

 public function base()
 {
     $results = array();
     $query = isset($_GET['q']) ? $_GET['q'] : false;
     $search = $query;
     if ($query !== false) {
         $stemmer = new PorterStemmer();
         $index = new indexes($this->getDb());
         $file = new files($this->getDb());
         $scores = array();
         $terms = explode(' ', $query);
         $db_searches = new searches($this->getDb());
         foreach ($terms as $term) {
             if ($term != '') {
                 $old = $db_searches->select('*', 'WHERE term="' . $term . '"');
                 if (isset($old[0]['id'])) {
                     $db_searches->update(array('count' => ++$old[0]['count'], 'date' => time()), 'WHERE term="' . $term . '"');
                 } else {
                     $db_searches->insert(array('term' => $term, 'count' => 1, 'date' => time()));
                 }
             }
         }
         $term_weight = 0.05;
         $wpm_weight = 5;
         //7
         $count_weight = 150;
         //135
         $count = 0;
         foreach ($terms as $term) {
             $term = 'indx-' . $stemmer->Stem($term);
             $data = $index->select('*', 'WHERE stem="' . $term . '" ORDER BY wpm DESC, count DESC LIMIT 0, 100');
             foreach ($data as $file_data) {
                 $file_id = $file_data['file'];
                 $wpm = $file_data['wpm'];
                 $index_count = $file_data['count'];
                 $weight = $wpm * $wpm_weight * (1 - $term_weight * $count) + $index_count * $count_weight * (1 - $term_weight * $count);
                 if (isset($scores[$file_id])) {
                     $scores[$file_id] += $weight;
                 } else {
                     $scores[$file_id] = $weight;
                 }
             }
             $count++;
         }
         arsort($scores);
         foreach ($scores as $key => $score) {
             $results[$key] = array();
             $results[$key]['score'] = $score;
         }
         $ids = array_keys($scores);
         $files = array();
         if (count($ids) > 0) {
             $files = $file->select('*', 'WHERE id IN (' . implode(', ', $ids) . ')');
         }
         foreach ($files as $selected) {
             $results[$selected['id']]['id'] = $selected['id'];
             $results[$selected['id']]['name'] = $selected['name'];
             $results[$selected['id']]['link'] = $selected['link'];
         }
         $this->set('results', $results);
     } else {
         $this->set('results', $results);
     }
     $this->set('search', $search);
     $searches = new searches($this->getDb());
     $this->set('popular', $searches->select('*', 'ORDER BY count DESC LIMIT 0, 10'));
 }
开发者ID:sudhanshuraheja,项目名称:PDF-Search,代码行数:67,代码来源:homeController.php


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