Skip to content

Commit c869481

Browse files
committed
refactor notLike() method
1 parent 5ce6cf0 commit c869481

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/QueryBuilder.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,23 @@ public function like($field, string $value = ''): QueryBuilder
592592
}
593593

594594
/**
595-
* @param array|string $cond
595+
* @param array|string $field
596+
* @param string $value
596597
* @return $this
597598
*/
598-
public function notLike($cond = []): QueryBuilder
599+
public function notLike($field, string $value = ''): QueryBuilder
599600
{
600-
if ($cond) {
601-
if (is_string($cond)) {
602-
$this->where($cond);
603-
} else if (is_array($cond)) {
604-
$this->where([[$cond[0], 'NOT LIKE', $cond[1]]]);
605-
}
601+
if (empty($field)) {
602+
$this->setError('Empty $field in ' . __METHOD__);
603+
return $this;
604+
}
605+
606+
if (is_string($field) && !empty($field) && is_string($value) && !empty($value)) {
607+
$this->where([[$field, 'NOT LIKE', $value]]);
608+
} else if (is_string($field) && empty($value)) {
609+
$this->where($field);
610+
} else if (is_array($field)) {
611+
$this->where([[$field[0], 'NOT LIKE', $field[1]]]);
606612
}
607613

608614
return $this;

0 commit comments

Comments
 (0)