Releases: davahome/database
Added PHP 8.1+ support
General
- Dropped PHP 7 support
- New minimum required version: 8.1
- Enforced PHP8 types on methods (mainly type
mixedas all other types were present since v2.0)
Testing
- Removed all obsolete build configurations (travis, Jenkins)
- Added GitHub Actions build pipeline
- Relaced PHPunit with Pest PHP
v2.0
General
- Dropped PHP 5 support
- New minimum required version: 7.4
- Enforced PHP7 types on methods
- Moved classes into new namespaces
DavaHome\Database\DatabaseInterface=>DavaHome\Database\Adapter\AdapterInterfaceMysql,Pdo&Sqlite3=> fromDavaHome\DatabasetoDavaHome\Database\AdapterDirectValue&CustomOperator=> fromDavaHome\DatabasetoDavaHome\Database\Extension
Mysql
- New default encoding => from
utf8toutf8mb4
1.6.1
Isolation Level Constants, DatabaseInterface, UTF8
Isolation Level Constants
The Mysql class has now a set of isolation level constants and a helper method for setting the level.
# New constants
Mysql::ISOLATION_LEVEL_READ_UNCOMITTED
Mysql::ISOLATION_LEVEL_READ_COMMITTED
Mysql::ISOLATION_LEVEL_REPEATABLE_READ
Mysql::ISOLATION_LEVEL_SERIALIZABLE
# New method
void setIsolationLevel($isolationLevel)
# Example
$mysql = new Mysql();
$mysql->setIsolationLevel(Mysql::ISOLATION_LEVEL_SERIALIZABLE);DatabaseInterface
There is a new interface which defines the core functionality (update, insert, select and delete). Future wrappers (like Sqlite3) will implement this interface as well.
DavaHome\Database\DatabaseInterfaceUTF8
The Mysql class will now perform a second query on initial connection:
SET CHARACTER SET utf8Documentation
Updated the Readme and fixed some syntax errors in demo code.
Notes
Warning: Despite its existence the DavaHome\Database\Sqlite3 class shouldn't be used yet.
Allow empty where-statements for select
It is now possible to give an empty array to ->select() without creating an error but the parameter $where is still required
$db->select('table', []);Added CustomOperator
Regular query building
Input
['foo' => 'bar']Query
`foo` = :value_0CustomOperator query building
Input
use DavaHome\Database\CustomOperator;
['foo' => new CustomOperator('!=', 'bar')]Query
`foo` != :value_0Advanced CustomOperator query building
Input
use DavaHome\Database\CustomOperator;
use DavaHome\Database\DirectValue;
['foo' => new CustomOperator('!=', new DirectValue('NOW()'))]Query
`foo` != NOW()Fixed custom options for PDO
- $options = array_merge([
+ $options = array_replace([Added createUuid()
$db = new \DavaHome\Database\Mysql();
$uuid = $db->createUuid();Commit: 3060047
UUID() Documentation: https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_uuid
Added select() and delete()
$db = new \DavaHome\Database\Mysql();
$pdoStatement = $db->select('table', ['id' => 1]);
$pdoStatement = $db->delete('table', ['id' => 1]);Fixed undefined constant error
CRIT (2): Error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in src/DavaHome/Database/Mysql.php:16