marwelln / exists
在 Laravel 中运行 exists 查询
v1.0.5
2020-09-19 17:07 UTC
Requires
- php: >=7.0
- illuminate/database: >=5.0
README
composer require marwelln/exists:~1.0
用法
$exists = Marwelln\Exists::table('mytable')->where('statement', 'value')->check(); // true or false
$exists = (new Marwelln\Exists('mytable'))->where('statement', 'value')->check(); // true or false
可用方法
static table(string $table)
设置我们想要运行 EXISTS
的表。如果需要,可以使用构造函数。
where(string $key, mixed $value, string $operator = '=') // WHERE key {$operator} value
whereBetween(string $key, string $field1, string $field2) // WHERE key BETWEEN field1 AND field2
whereNull(string $key) // WHERE key IS NULL
whereNotNull(string $key) // WHERE key IS NOT NULL
添加 WHERE
语句。这可以链接使用。
check()
// SELECT EXISTS(SELECT 1 FROM table WHERE statements) AS `exists`
运行查询。如果行存在,则返回 true
,否则返回 false
。