Marwelln / Exists by Marwelln

Run exists queries in Laravel
30
0
2
Package Data
Maintainer Username: Marwelln
Maintainer Contact: marwelln@redward.se (Martin Mårtensson)
Package Create Date: 2016-06-01
Package Last Update: 2020-09-19
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:01:22
Package Statistics
Total Downloads: 30
Monthly Downloads: 3
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Installation

composer require marwelln/exists:~1.0

Usage

$exists = Marwelln\Exists::table('mytable')->where('statement', 'value')->check(); // true or false

$exists = (new Marwelln\Exists('mytable'))->where('statement', 'value')->check(); // true or false

Available methods

static table(string $table)

Sets the table we want to run EXISTS with. Can use constructor instead if wanted.

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

Add WHERE statements. This can be chained.

check()
// SELECT EXISTS(SELECT 1 FROM table WHERE statements) AS `exists`

Run the query. Will return true or false depending on if the row existed or not.