Documentation MyBrickStore

ImagesModel extends Model
in package

Class ImagesModel

  • Manages user-uploaded images stored as blobs in the database
  • Handles the separation between metadata (image table) and binary data (customerimage table)

Table of Contents

Properties

$table  : string

Methods

find()  : mixed
Finds a specific record by its ID.
findAll()  : array<string|int, mixed>|false
Retrieves all records from the associated table.
getImageById()  : mixed
Retrieves image data and metadata by id
getLastImageByUserId()  : mixed
Fetches the most recently uploaded image for a specific user
requete()  : PDOStatement|false
Executes a SQL query (prepared or direct).
saveCustomerImage()  : int
Saves a new image by creating linked records in both image tables
updateCustomerImageBlob()  : bool
Updates the binary content of an existing image (e.g. after cropping)

Properties

$table

protected string $table = 'Image'

The database table associated with the model.

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.

getImageById()

Retrieves image data and metadata by id

public getImageById(int $id[, int|null $userId = null ]) : mixed
Parameters
$id : int

image identifier

$userId : int|null = null

optional user id for strict ownership check

Return values
mixed

image object or false

getLastImageByUserId()

Fetches the most recently uploaded image for a specific user

public getLastImageByUserId(int $userId) : mixed
Parameters
$userId : int
Return values
mixed

image object or false

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.

saveCustomerImage()

Saves a new image by creating linked records in both image tables

public saveCustomerImage(int $idCustomer, string $imgData, string $fileName, string $mimeType) : int
Parameters
$idCustomer : int

owner identifier

$imgData : string

binary content of the file

$fileName : string

original name of the file

$mimeType : string

mime type (e.g. image/png)

Tags
throws
PDOException

if the transaction fails

Return values
int

the new image identifier

updateCustomerImageBlob()

Updates the binary content of an existing image (e.g. after cropping)

public updateCustomerImageBlob(int $idImage, int $idCustomer, string $newData) : bool
Parameters
$idImage : int
$idCustomer : int

used for ownership verification

$newData : string

new binary data

Return values
bool

success status


        
On this page

Search results