aboutsummaryrefslogtreecommitdiff
path: root/src/Search/AbstractFTSExpr.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/AbstractFTSExpr.php
downloadmicropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.gz
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.bz2
micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.zip
Initial commit
Diffstat (limited to 'src/Search/AbstractFTSExpr.php')
-rw-r--r--src/Search/AbstractFTSExpr.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Search/AbstractFTSExpr.php b/src/Search/AbstractFTSExpr.php
new file mode 100644
index 0000000..b72b1b6
--- /dev/null
+++ b/src/Search/AbstractFTSExpr.php
@@ -0,0 +1,31 @@
+<?php
+
+
+namespace Micropoly\Search;
+
+
+abstract class AbstractFTSExpr implements SearchExpr
+{
+ abstract protected function fts4Query(): string;
+
+ public function toSQL(string $bindPrefix, bool $singleFTS): SQLSearchExpr
+ {
+ $sqlex = new SQLSearchExpr();
+
+ $sqlex->sql = $singleFTS
+ ? "nc.note_contents MATCH :{$bindPrefix}match"
+ : "n.content_row IN (
+ SELECT rowid
+ FROM note_contents
+ WHERE note_contents MATCH :{$bindPrefix}match
+ )";
+ $sqlex->bindings["{$bindPrefix}match"] = $this->fts4Query();
+
+ return $sqlex;
+ }
+
+ public function countFTSQueries(): int
+ {
+ return 1;
+ }
+} \ No newline at end of file