Where
in package
Represents a WHERE clause in a SQL query.
This class provides methods for building a WHERE clause in a SQL query.
Table of Contents
Properties
- $placeholders : array<string, mixed>
- $sql : string
Methods
- getPlaceholders() : array<string, mixed>
- Get the placeholders used in the query.
- getSql() : string
- Get the SQL string for the WHERE clause.
- reset() : void
- Resets the conditions in the WHERE clause of the query.
- set() : void
- Constructor.
Properties
$placeholders
private
array<string, mixed>
$placeholders
= []
Placeholder values for PDO prepared statements
$sql
private
string
$sql
= ''
SQL query string
Methods
getPlaceholders()
Get the placeholders used in the query.
public
getPlaceholders() : array<string, mixed>
Return values
array<string, mixed> —The array of placeholders.
getSql()
Get the SQL string for the WHERE clause.
public
getSql() : string
Return values
string —The SQL string for the WHERE clause.
reset()
Resets the conditions in the WHERE clause of the query.
public
reset() : void
This method clears any previously set conditions in the WHERE clause of the query, allowing you to start building a new set of conditions.
set()
Constructor.
public
set([array<int|string, mixed>|string $where = '' ]) : void
Builds a SQL WHERE clause from an array
Parameters
- $where : array<int|string, mixed>|string = ''
-
String or Array containing the fields and values or a string Example: $where = 'id > 1234'; or: $where['id >'] = 1234; $where[] = 'first_name IS NOT NULL'; $where['some_value <>'] = 'text';