AutoMapped
in package
The AutoMapped class is a database abstraction layer that provides: - Database connection management with configuration support - Table name handling with prefix functionality - Type conversion utilities for database operations - Query building assistance through method chaining - Transaction handling capabilities - Identifier quoting and escaping
This class serves as a foundation for database interactions in PHP applications, abstracting away low-level database specifics while providing convenient utility methods. It's designed to work with Doctrine DBAL for database operations and provides additional helpful methods for common database tasks.
Key features include:
- Dynamic table name resolution with prefix support
- Type conversion between PHP and database formats
- Automated transaction handling
- Flexible column/property name mapping
- Support for different database drivers through Doctrine DBAL
Usage example:
$db = new AutoMapped($config);
$users = $db->table('users')->where('active', 1)->fetchAll();
Table of Contents
Methods
- mapValueFromDB() : mixed
- Maps a value from database to its PHP representation based on type
- mapValueFromPHP() : mixed
- Maps a PHP value to its corresponding database representation based on type.
Methods
mapValueFromDB()
Maps a value from database to its PHP representation based on type
public
static mapValueFromDB(int|string $value, string $type) : mixed
Parameters
- $value : int|string
-
The value as retrieved from the database
- $type : string
-
The database column type
Return values
mixed —The value properly typed for PHP usage
mapValueFromPHP()
Maps a PHP value to its corresponding database representation based on type.
public
static mapValueFromPHP(int|string $value, string $type) : mixed
Parameters
- $value : int|string
-
The input value to be mapped.
- $type : string
-
The expected data type for mapping (e.g., 'string', 'int', 'datetime').
Return values
mixed —The value after being processed or converted according to the specified type.