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


PHP rex_sql::flush方法代码示例

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


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

示例1: indexColumn

 /**
  * Indexes a certain column.
  * Returns the number of the indexed rows or false.
  * 
  * @param string $_table
  * @param mixed $_column
  * @param mixed $_idcol
  * @param mixed $_id
  * @param mixed $_start
  * @param mixed $_count
  * 
  * @return mixed
  */
 function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start = false, $_count = false, $_where = false)
 {
     $delete = new rex_sql();
     $where = sprintf(" `ftable` = '%s' AND `fcolumn` = '%s' AND `texttype` = 'db_column'", $delete->escape($_table), $delete->escape($_column));
     //if(is_string($_idcol) AND ($_id !== false))
     //$where .= sprintf(' AND fid = %d',$_id);
     // delete from cache
     $select = new rex_sql();
     $select->setTable($this->tablePrefix . '587_searchindex');
     $select->setWhere($where);
     $indexIds = array();
     if ($select->select('id')) {
         foreach ($select->getArray() as $result) {
             $indexIds[] = $result['id'];
         }
         $this->deleteCache($indexIds);
     }
     // delete old data
     if ($_start === 0) {
         $delete->setTable($this->tablePrefix . '587_searchindex');
         $delete->setWhere($where);
         $delete->delete();
     }
     $sql = new rex_sql();
     // get primary key column(s)
     $primaryKeys = array();
     foreach ($sql->getArray("SHOW COLUMNS FROM `" . $_table . "` WHERE `KEY` = 'PRI'") as $col) {
         $primaryKeys[] = $col['Field'];
     }
     // index column
     $sql->flush();
     $sql->setTable($_table);
     $where = '1 ';
     if (is_string($_idcol) and $_id) {
         $where .= sprintf(' AND (%s = %d)', $_idcol, $_id);
     }
     if (!empty($_where) and is_string($_where)) {
         $where .= ' AND (' . $_where . ')';
     }
     if (is_numeric($_start) and is_numeric($_count)) {
         $where .= ' LIMIT ' . $_start . ',' . $_count;
     }
     $sql->setWhere($where);
     $count = false;
     if ($sql->select('*')) {
         $this->beginFrontendMode();
         $count = 0;
         $keywords = array();
         foreach ($sql->getArray() as $value) {
             if (!empty($value[$_column]) and ($this->indexOffline or $this->tablePrefix . 'article' != $_table or $value['status'] == '1') and ($this->tablePrefix . 'article' != $_table or !in_array($value['id'], $this->excludeIDs))) {
                 $insert = new rex_sql();
                 $indexData = array();
                 $indexData['texttype'] = 'db_column';
                 $indexData['ftable'] = $_table;
                 $indexData['fcolumn'] = $_column;
                 if (array_key_exists('clang', $value)) {
                     $indexData['clang'] = $value['clang'];
                 } else {
                     $indexData['clang'] = NULL;
                 }
                 $indexData['fid'] = NULL;
                 if (is_string($_idcol) and array_key_exists($_idcol, $value)) {
                     $indexData['fid'] = $value[$_idcol];
                 } elseif ($_table == $this->tablePrefix . 'article') {
                     $indexData['fid'] = $value['id'];
                 } elseif (count($primaryKeys) == 1) {
                     $indexData['fid'] = $value[$primaryKeys[0]];
                 } elseif (count($primaryKeys)) {
                     $fids = array();
                     foreach ($primaryKeys as $pk) {
                         $fids[$pk] = $value[$pk];
                     }
                     $indexData['fid'] = json_encode($fids);
                 }
                 if (is_null($indexData['fid'])) {
                     $indexData['fid'] = $this->getMinFID();
                 }
                 if (array_key_exists('re_id', $value)) {
                     $indexData['catid'] = $value['re_id'];
                     if ($_table == $this->tablePrefix . 'article') {
                         $indexData['catid'] = intval($value['startpage']) ? $value['id'] : $value['re_id'];
                     }
                 } elseif (array_key_exists('category_id', $value)) {
                     $indexData['catid'] = $value['category_id'];
                 } else {
                     $indexData['catid'] = NULL;
                 }
//.........这里部分代码省略.........
开发者ID:olien,项目名称:rexsearch,代码行数:101,代码来源:class.rexsearch.inc.php


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