Search queries: added new feature - "comment:x"

This commit is contained in:
Marcin Kurczewski 2013-11-21 14:13:26 +01:00
parent b2fdbb914e
commit a892410f5d
2 changed files with 20 additions and 0 deletions

View file

@ -216,6 +216,25 @@ class Model_Post_QueryBuilder implements AbstractQueryBuilder
return self::filterTokenFav($dbQuery, $val); return self::filterTokenFav($dbQuery, $val);
} }
protected static function filterTokenComment($dbQuery, $val)
{
$dbQuery
->exists()
->open()
->select('1')
->from('comment')
->innerJoin('user')
->on('commenter_id = user.id')
->where('post_id = post.id')
->and('user.name = ?')->put($val)
->close();
}
protected static function filterTokenCommenter($dbQuery, $val)
{
return self::filterTokenComment($dbQuery, $val);
}
protected static function filterTokenSubmit($dbQuery, $val) protected static function filterTokenSubmit($dbQuery, $val)
{ {
$dbQuery $dbQuery

View file

@ -22,6 +22,7 @@
<li>uploaded by David: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'submit:David']) ?>"><code>submit:David</code></a> (note no spaces)</li> <li>uploaded by David: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'submit:David']) ?>"><code>submit:David</code></a> (note no spaces)</li>
<li>favorited by David: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'fav:David']) ?>"><code>fav:David</code></a></li> <li>favorited by David: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'fav:David']) ?>"><code>fav:David</code></a></li>
<li>favorited by at least four users: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'favmin:4']) ?>"><code>favmin:4</code></a></li> <li>favorited by at least four users: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'favmin:4']) ?>"><code>favmin:4</code></a></li>
<li>commented by David: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'comment:David']) ?>"><code>comment:David</code></a></li>
<li>commented by at least three users: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'commentmin:3']) ?>"><code>commentmin:3</code></a></li> <li>commented by at least three users: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'commentmin:3']) ?>"><code>commentmin:3</code></a></li>
<li>having minimum score of 4: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'scoremin:4']) ?>"><code>scoremin:4</code></a></li> <li>having minimum score of 4: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'scoremin:4']) ?>"><code>scoremin:4</code></a></li>
<li>tagged with at least seven tags: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'tagmin:7']) ?>"><code>tagmin:7</code></a></li> <li>tagged with at least seven tags: <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => 'tagmin:7']) ?>"><code>tagmin:7</code></a></li>