aboutsummaryrefslogtreecommitdiff
path: root/src/Search/TagExpr.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
committerLaria Carolin Chabowski <laria@laria.me>2020-02-07 09:44:59 +0100
commit2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (patch)
treeab57978bdda34c82b025b897cfb6825b1fd1e654 /src/Search/TagExpr.php
downloadmicropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.gz
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.bz2
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.zip
Initial commit
Diffstat (limited to 'src/Search/TagExpr.php')
-rw-r--r--src/Search/TagExpr.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Search/TagExpr.php b/src/Search/TagExpr.php
new file mode 100644
index 0000000..b117bbe
--- /dev/null
+++ b/src/Search/TagExpr.php
@@ -0,0 +1,42 @@
+<?php
+
+
+namespace Micropoly\Search;
+
+
+class TagExpr implements SearchExpr
+{
+ private string $tag;
+
+ public function __construct(string $tag)
+ {
+ $this->tag = $tag;
+ }
+
+ public function getTag(): string { return $this->tag; }
+
+ public function toString(): string
+ {
+ return "#{$this->tag}";
+ }
+
+ public function toSQL(string $bindPrefix, bool $singleFTS): SQLSearchExpr
+ {
+ $sqlex = new SQLSearchExpr();
+
+ $sqlex->sql = "EXISTS (
+ SELECT 1
+ FROM tags t
+ WHERE t.tag = :{$bindPrefix}tag
+ AND t.note_id = n.id
+ )";
+ $sqlex->bindings["{$bindPrefix}tag"] = $this->tag;
+
+ return $sqlex;
+ }
+
+ public function countFTSQueries(): int
+ {
+ return 0;
+ }
+} \ No newline at end of file