Releases: PhpGt/Database
Refactored and restyled
- All CodeSniffer inspections are resolved.
- The updated PHP.Gt/StyleGuide has been adhered to.
- CircleCI updated to 2.0
Variable argument bugfixes
Allowing named or ordered bindings utilised the new PHP feature of variable arguments, using the ...
operator. This new feature, coupled with the shorthand helper methods caused a situation where bindings could be doubly nested.
Shorter more expressive syntax
The introduction of the concept of a QueryCollection meant that longhand API usage was too wordy and had too many steps to perform simple operations.
This release includes a new shorter syntax and due to this syntax being preferred, dropping accessing QueryCollection via ArrayAccess (backwards breaking).
New syntax:
$db = new Client();
$customer = $db->fetch("customer/getById", ["id" => 123]);
$customerList = $db->fetchAll("customer/getInTown", ["town" => "London"]);
$newCustomerId = $db->insert("customer/create", $details);
$updatedCount = $db->update("customer/setDetails", $details);
$deletedCount = $db->delete("customer/deleteOlderThan", ["createdAt" =>new DateTime("-30 days")]);
Pure PDO dependency
As in v1 we are not supporting any QueryBuilder or SchemaBuilder, we're dropping the requirement of Illuminate's database layer. There was no benefit from the heavy reliance on Reflection, so now it's been removed and there is only a dependency on PDO itself.
Connection and migration changes
- Set port number in settings constructor
- Refactor db-migrate script
- Dependencies updated to avoid major bug with Illuminate's dependency injector
Variable argument queries for question mark parameters
Certain queries are better to use ?
placeholders rather than :named
placeholders, typically queries where the placeholder can be inferred by the query name.
For example, the getById
query should only take the one parameter, which doesn't need to be named "id" when calling.
Clean, improved syntax:
$customer = $db["customer"]->getById(123);
Rather than:
$customer = $db["customer"]->getById(["id" => 123]);
Migration integrity
During migration, each migration script is hashed and stored in the database to prevent accidental edits to already-migrated scripts. The migration tool will halt without altering the database if any edit is detected.
Major bugfixes
Many bugs have been fixed working with subsequent query calls.
Migrations
Basic database migration functionality implemented.
Updates to ResultSet
Rows are now Iterable.
Exceptions are thrown by default.
Parameters have their placeholder characters set by default.
ResultSet::hasResult added.