Crud
extends Database
in package
Create, Read, Update and Delete actions on a database table.
Table of Contents
Properties
- $db : mixed
Methods
- __construct() : Connection
- read() : array<int, array<string, mixed>>
- Prepare and run a read query, then return its rows.
- delete() : array<int, array<string, mixed>>
- Prepare and run a delete query, then return its result.
- process() : array<int, array<string, mixed>>
- Return all rows of an executed statement as associative arrays.
- save() : array<int, array<string, mixed>>
- Prepare and run a write query, then return its result.
Properties
$db
protected
static mixed
$db
Methods
__construct()
public
final __construct() : Connection
Tags
Return values
Connection —between PHP and a database server or and E_USER_ERROR.
read()
Prepare and run a read query, then return its rows.
protected
final read(string $sql[, array<int, array{0: string, 1: mixed, 2: int, 3: int}>|false $param = false ]) : array<int, array<string, mixed>>
Parameters
- $sql : string
-
SQL query with bind placeholders.
- $param : array<int, array{0: string, 1: mixed, 2: int, 3: int}>|false = false
-
Bind parameters (each: [name, value, PDO type, length]), or false for none.
Return values
array<int, array<string, mixed>> —The result rows.
delete()
Prepare and run a delete query, then return its result.
private
delete(string $sql, array<int, array{0: string, 1: mixed, 2: int, 3: int}> $param) : array<int, array<string, mixed>>
Parameters
- $sql : string
-
SQL query with bind placeholders.
- $param : array<int, array{0: string, 1: mixed, 2: int, 3: int}>
-
Bind parameters (each: [name, value, PDO type, length]).
Return values
array<int, array<string, mixed>> —The result rows.
process()
Return all rows of an executed statement as associative arrays.
private
process(PDOStatement $query) : array<int, array<string, mixed>>
Parameters
- $query : PDOStatement
-
Executed statement.
Return values
array<int, array<string, mixed>> —The result rows.
save()
Prepare and run a write query, then return its result.
private
save(string $sql, array<string|int, array{0: string, 1: mixed, 2: int, 3: int}> $param) : array<int, array<string, mixed>>
Parameters
- $sql : string
-
SQL query with bind placeholders.
- $param : array<string|int, array{0: string, 1: mixed, 2: int, 3: int}>
-
Bind parameters keyed arbitrarily (each: [name, value, PDO type, length]).
Return values
array<int, array<string, mixed>> —The result rows.