Model
in package
Class Model
- Base Model Class providing generic database interaction methods.
- Implements common CRUD operations using the Db Singleton.
Table of Contents
Properties
Methods
- find() : mixed
- Finds a specific record by its ID.
- findAll() : array<string|int, mixed>|false
- Retrieves all records from the associated table.
- requete() : PDOStatement|false
- Executes a SQL query (prepared or direct).
Properties
$table
protected
string
$table
The database table associated with the model.
$db
private
string
$db
The database
Methods
find()
Finds a specific record by its ID.
public
find(int $id) : mixed
Parameters
- $id : int
-
The record identifier.
Return values
mixed —The record object or false if not found.
findAll()
Retrieves all records from the associated table.
public
findAll() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false —List of records.
requete()
Executes a SQL query (prepared or direct).
public
requete(string $sql[, array<string|int, mixed>|null $attributs = null ]) : PDOStatement|false
Parameters
- $sql : string
-
The SQL query string.
- $attributs : array<string|int, mixed>|null = null
-
Optional parameters for prepared statements.
Return values
PDOStatement|false —The result statement.