Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cbb8815

Browse filesBrowse files
authored
Update ssql.php
Improved escaping of begins, ends and contains conditions, improved their compatibility with SQLite.
1 parent 1922c5f commit cbb8815
Copy full SHA for cbb8815

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed

‎ssql.php

Copy file name to clipboardExpand all lines: ssql.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,9 @@ public function begins(string $k, $v, int $flags = 128) {
10521052
if(is_array($v) && count($v) < 1)
10531053
return false;
10541054
if(is_array($v))
1055-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE '" . $this->c->escape($v[0]) . "%'") : ("(`" . $this->c->escape($k) . "` LIKE '" . $this->c->escape(array_shift($v)) . "%') OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
1055+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "(" : "CONCAT(") . $this->quote($v[0]) . ($this->c->SQLite ? " || '%')" : ", '%')")) : ("(`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "(" : "CONCAT(") . $this->quote(array_shift($v)) . ($this->c->SQLite ? " || '%')" : ", '%')") . ") OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
10561056
else
1057-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE CONCAT(`" . $this->c->escape($v) . "`, '%')") . ($append ? ")" : "");
1057+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "(`" : "CONCAT(`") . $this->c->escape($v) . ($this->c->SQLite ? "` || '%')" : "`, '%')")) . ($append ? ")" : "");
10581058
return $this;
10591059
}
10601060
public function ends(string $k, $v, int $flags = 128) {
@@ -1066,9 +1066,9 @@ public function ends(string $k, $v, int $flags = 128) {
10661066
if(is_array($v) && count($v) < 1)
10671067
return false;
10681068
if(is_array($v))
1069-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE '%" . $this->c->escape($v[0]) . "'") : ("(`" . $this->c->escape($k) . "` LIKE '%" . $this->c->escape(array_shift($v)) . "') OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
1069+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || " : "CONCAT('%', ") . $this->quote($v[0]) . ")") : ("(`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || " : "CONCAT('%', ") . $this->quote(array_shift($v)) . ")" . ") OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
10701070
else
1071-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE CONCAT('%', `" . $this->c->escape($v) . "`)") . ($append ? ")" : "");
1071+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || `" : "CONCAT('%', `") . $this->c->escape($v) . "`)") . ($append ? ")" : "");
10721072
return $this;
10731073
}
10741074
public function contains(string $k, $v, int $flags = 128) {
@@ -1080,9 +1080,9 @@ public function contains(string $k, $v, int $flags = 128) {
10801080
if(is_array($v) && count($v) < 1)
10811081
return false;
10821082
if(is_array($v))
1083-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE '%" . $this->c->escape($v[0]) . "%'") : ("(`" . $this->c->escape($k) . "` LIKE '%" . $this->c->escape(array_shift($v)) . "%') OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
1083+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ((count($v) < 2) ? ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || " : "CONCAT('%', ") . $this->quote($v[0]) . ($this->c->SQLite ? " || '%')" : ", '%')")) : ("(`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || " : "CONCAT('%', ") . $this->quote(array_shift($v)) . ($this->c->SQLite ? " || '%')" : ", '%')") . ") OR (" . $this->c->cond()->like($k, $v) . ")")) . ($append ? ")" : "");
10841084
else
1085-
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE CONCAT('%', `" . $this->c->escape($v) . "`, '%')") . ($append ? ")" : "");
1085+
$this->cond = ($append ? ("({$this->cond}) " . ($flags & SQ::COND_OR ? "OR" : "AND") . " (") : "") . ("`" . $this->c->escape($k) . "` LIKE " . ($this->c->SQLite ? "('%' || `" : "CONCAT('%', `") . $this->c->escape($v) . ($this->c->SQLite ? "` || '%')" : "`, '%')")) . ($append ? ")" : "");
10861086
return $this;
10871087
}
10881088

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.