/** * 获得所有记录数 * * @access public * @param Typecho_Db_Query $condition 查询对象 * @return integer */ public function size(Typecho_Db_Query $condition) { return $this->db->fetchObject($condition->select(array('COUNT(id)' => 'num'))->from('table.creditslog'))->num; }
/** * set default params * * @param array $default */ public static function setDefault(array $default) { self::$_default = array_merge(self::$_default, $default); }
/** * 删除记录方法 * * @access public * @param Typecho_Db_Query $condition 查询对象 * @return integer */ public function delete(Typecho_Db_Query $condition) { return $this->db->query($condition->delete('table.users')); }
/** * 按照条件计算内容数量 * * @access public * @param Typecho_Db_Query $condition 查询对象 * @return integer */ public function size(Typecho_Db_Query $condition) { return $this->db->fetchObject($condition->select(array('COUNT(DISTINCT table.favorites.fid)' => 'num'))->from('table.favorites')->cleanAttribute('group'))->num; }
/** * 处理搜索 * * @access private * @param Typecho_Db_Query $select 查询对象 * @param boolean $hasPushed 是否已经压入队列 * @return void */ private function searchHandle(Typecho_Db_Query $select, &$hasPushed) { /** 增加自定义搜索引擎接口 */ //~ fix issue 40 $keywords = $this->request->filter('url', 'search')->keywords; $this->pluginHandle()->trigger($hasPushed)->search($keywords, $this); if (!$hasPushed) { $searchQuery = '%' . str_replace(' ', '%', $keywords) . '%'; /** 搜索无法进入隐私项保护归档 */ $select->where('table.contents.password IS NULL')->where('table.contents.title LIKE ? OR table.contents.text LIKE ?', $searchQuery, $searchQuery)->where('table.contents.type = ?', 'post'); } /** 设置关键词 */ $this->_keywords = $keywords; /** 设置分页 */ $this->_pageRow = array('keywords' => urlencode($keywords)); /** 设置头部feed */ /** RSS 2.0 */ $this->_feedUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedUrl); /** RSS 1.0 */ $this->_feedRssUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedAtomUrl); /** ATOM 1.0 */ $this->_feedAtomUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedAtomUrl); /** 设置标题 */ $this->_archiveTitle = $keywords; /** 设置归档类型 */ $this->_archiveType = 'search'; /** 插件接口 */ $this->pluginHandle()->searchHandle($this, $select); }