Home >Backend Development >PHP Tutorial >%t WHERE 1 %i 里面的%t和%i,是如何控制的。

%t WHERE 1 %i 里面的%t和%i,是如何控制的。

WBOY
WBOYOriginal
2016-06-13 12:08:561170browse

%t WHERE 1 %i 里面的%t和%i,是怎么控制的。。
下面的代码,是怎么实现控制%t和%i输出的结果啊。。?

<br />public function fetch_all_by_search($tableid, $tid = null, $keywords = null, $invisible = null, $fid = null, $authorid = null, $author = null, $starttime = null, $endtime = null, $useip = null, $first = null, $start = null, $limit = null) {<br />		$sql = '';<br />		$sql .= $tid ? ' AND '.DB::field('tid', $tid) : '';<br />		$sql .= $authorid ? ' AND '.DB::field('authorid', $authorid) : '';<br />		$sql .= $invisible !== null ? ' AND '.DB::field('invisible', $invisible) : '';<br />		$sql .= $first !== null ? ' AND '.DB::field('first', $first) : '';<br />		$sql .= $fid ? ' AND '.DB::field('fid', $fid) : '';<br />		$sql .= $author ? ' AND '.DB::field('author', $author) : '';<br />		$sql .= $starttime ? ' AND '.DB::field('dateline', $starttime, '>=') : '';<br />		$sql .= $endtime ? ' AND '.DB::field('dateline', $endtime, '<') : '';<br />		$sql .= $useip ? ' AND '.DB::field('useip', $useip, 'like') : '';<br />		if(trim($keywords)) {<br />			$sqlkeywords = $or = '';<br />			foreach(explode(',', str_replace(' ', '', $keywords)) as $keyword) {<br />				$keyword = addslashes($keyword);<br />				$sqlkeywords .= " $or message LIKE '%$keyword%'";<br />				$or = 'OR';<br />			}<br />			$sql .= " AND ($sqlkeywords)";<br />		}<br />		if($sql) {<br />			return DB::fetch_all('SELECT * FROM %t WHERE 1 %i ORDER BY dateline DESC %i', array(self::get_tablename($tableid), $sql, DB::limit($start, $limit)));<br />		} else {<br />			return array();<br />		}<br />	}<br />

------解决思路----------------------
那你看看 DB::fetch_all 的定义

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn