The Problem
Ignoring specific values, when arrays are pulled, using medoo, and merged.
The Details
Say I have two arrays, created from two similar tables. They have a 'user'-row and an 'id'-row. Example below:
id name
------- ---------
1 John Doe
2 John Snow
3 Jane
4 Jane
What is the best way to ignore all entries that have 'John ...' in the name row? My array_merge is currently like this:
public function getUsersByName($name)
{
$res = array_merge(
$this->_db->select('users1', ['id', 'name'],
$this->_db->select('users2', ['id', 'name']
);
return $res;
}
This returns a nice array, with all values in the tables. What is the best practice to ignore those values, and skip to the next legitimate value?
To run queries with
WHERE .. NOT LIKE ..
in medoo, you can pass a third parameter toselect()
that contains an array of the where clauses. The key is the column with the operator, and the value is - well, the value.For example, to select from
users1
where no names begin withJohn
, you'll needThe
[!~]
signalizesNOT LIKE
.