1
我試圖用類似SQL的語法查詢數組,並且我正在瞭解YaLinqo。YaLinqo - 獲取包含等於運算符的where子句的正確結果
我設法讓它適用於具有上級或下級操作符的where子句,但我不能讓它與equals操作符一起工作。
我在做什麼錯?
下面的例子:
require_once __DIR__ . '/vendor/autoload.php';
use \YaLinqo\Enumerable;
$users = [
[
'UserId' => '1',
'username' => 'joe',
'password' => 'joepw',
'mail' => '[email protected]'
],
[
'UserId' => '2',
'username' => 'nancy',
'password' => 'nancypw',
'mail' => '[email protected]'
],
[
'UserId' => '3',
'username' => 'alice',
'password' => 'alicepw',
'mail' => '[email protected]'
]
];
$working = \YaLinqo\Enumerable::from($users)
->where('$users ==> $users["UserId"] > 2')
->toArray();
$notWorking = \YaLinqo\Enumerable::from($users)
->where('$users ==> $users["UserId"] = 2')
->toArray();
$workingAndUgly = \YaLinqo\Enumerable::from($users)
->where('$users ==> $users["UserId"] > 1')
->where('$users ==> $users["UserId"] < 3')
->toArray();
$notWorkingEither = \YaLinqo\Enumerable::from($users)
->where('$users ==> $users["username"] = "nancy"')
->toArray();
var_dump($working, $notWorking, $workingAndUgly, $notWorkingEither);