Query Class
Aurora\Database\Query Namespace
Interfaces
- I Stringable
Properties
connection
Connection name
protected $connection = 'default': string
model
Model class
protected $model: string
blank
Empty flag
protected $blank = 1: bool
database
Database instance
protected $database: \Database
blueprint
Query Blueprint
protected $blueprint: \Blueprint
Constructor
__construct
Constructor
Parameters
Aurora\Database\Database
$database
— Database instance
Signature
public function __construct(Aurora\Database\Database $database)
Methods
__construct
Constructor
Parameters
-
Aurora\Database\Database
$database
— Database instance
Signature
public function __construct(Aurora\Database\Database $database)
setConnection
Set connection name
Parameters
-
string
$connection
— Connection name
Return Value
$this
Signature
public function setConnection(string $connection)
setModel
Set query model
Parameters
-
string
$model
— Model class
Return Value
$this
Signature
public function setModel(string $model)
getConnection
Get connection name
Return Value
string
Signature
public function getConnection()
getBlueprint
Get query Blueprint
Return Value
\Blueprint
Signature
public function getBlueprint()
table
Set query table
Parameters
-
string
$table
— Table name -
string
$alias
— Table alias
Return Value
$this
Signature
public function table(string $table, string $alias = '')
from
Add table
Parameters
-
mixed
$table
— Table name -
string
$alias
— Table alias
Return Value
$this
Signature
public function from(mixed $table, string $alias = '')
column
Add column
Parameters
-
mixed
$column
— Column name -
string
$alias
— Column alias
Return Value
$this
Signature
public function column(mixed $column, string $alias = '')
join
Add join
Parameters
-
mixed
$table
— Table to join -
mixed
$first
— First column -
mixed
$second
— Second column -
string
$operator
— Comparison operator -
string
$type
— Join type
Return Value
$this
Signature
public function join(mixed $table, mixed $first, mixed $second, string $operator = '=', string $type = 'inner')
where
Add where clause
Parameters
-
mixed
$column
— Column -
mixed
$value
— Column value -
string
$operator
— Comparison operator -
string
$boolean
— Boolean operator
Return Value
$this
Signature
public function where(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND')
whereColumn
Add where clause for two columns
Parameters
-
mixed
$column
— Column -
mixed
$value
— Column value -
string
$operator
— Comparison operator -
string
$boolean
— Boolean operator
Return Value
$this
Signature
public function whereColumn(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND')
having
Add having clause
Parameters
-
mixed
$column
— Column -
mixed
$value
— Column value -
string
$operator
— Comparison operator -
string
$boolean
— Boolean operator
Return Value
$this
Signature
public function having(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND')
havingColumn
Add having clause for two columns
Parameters
-
mixed
$column
— Column -
mixed
$value
— Column value -
string
$operator
— Comparison operator -
string
$boolean
— Boolean operator
Return Value
$this
Signature
public function havingColumn(mixed $column, mixed $value, string $operator = '=', string $boolean = 'AND')
group
Add group clause
Parameters
-
mixed
$column
— Column -
string
$sort
— Sort order
Return Value
$this
Signature
public function group(mixed $column, string $sort = 'ASC')
order
Add order clause
Parameters
-
mixed
$column
— Column -
string
$sort
— Sort order
Return Value
$this
Signature
public function order(mixed $column, string $sort = 'ASC')
limit
Add limit clause
Parameters
-
int
$limit
— Limit -
int
$offset
— Offset
Return Value
$this
Signature
public function limit(int $limit, int $offset)
page
Paginate
Parameters
-
int
$page
— Page number -
int
$show
— Items per page
Return Value
$this
Signature
public function page(int $page, int $show = 100)
union
Union two queries
Parameters
-
Aurora\Database\Query\Query
$query
— Query to union
Return Value
$this
Signature
public function union(Aurora\Database\Query\Query $query)
all
Select all rows
Return Value
mixed
Signature
public function all()
first
Select single row
Return Value
mixed
Signature
public function first()
select
Select rows
Parameters
-
bool
$single
— Return single row
Return Value
mixed
Signature
public function select(bool $single)
insert
Insert rows
Parameters
-
array
$insert
— Data to insert
Return Value
mixed
Signature
public function insert(array $insert)
update
Update rows
Parameters
-
array
$update
— Data to update
Return Value
$this
Signature
public function update(array $update)
delete
Delete rows
Return Value
$this
Signature
public function delete()
truncate
Truncate table
Return Value
$this
Signature
public function truncate()
upsert
Upsert rows
Parameters
-
array
$insert
— Data to insert -
array
$update
— Data to update on index collision
Return Value
$this
Signature
public function upsert(array $insert, array $update)
count
Get row count
Parameters
-
mixed
$column
— Column
Return Value
int
Signature
public function count(mixed $column): int
min
Get minimum value
Parameters
-
mixed
$column
— Column
Return Value
mixed
Signature
public function min(mixed $column)
max
Get maximum value
Parameters
-
mixed
$column
— Column
Return Value
mixed
Signature
public function max(mixed $column)
avg
Get average value
Parameters
-
mixed
$column
— Column
Return Value
mixed
Signature
public function avg(mixed $column)
sum
Get sum value
Parameters
-
mixed
$column
— Column
Return Value
mixed
Signature
public function sum(mixed $column)
chunk
Chunk query
Parameters
-
Closure
$callback
— Callback function -
int
$size
— Chunk size -
mixed
$id
— Index field
Return Value
$this
Signature
public function chunk(Closure $callback, int $size, mixed $id = 'id')
dump
Dump current query
Return Value
$this
Signature
public function dump()
build
Build query
Return Value
\CompiledQuery
Signature
public function build(): Aurora\Database\Query\CompiledQuery
__toString
Convert to string
Return Value
string
Signature
public function __toString()