ezsystems/ezpublish-kernel
eZ Publish Kernel is the core of the eZ Publish/eZ Platform CMS, providing the content repository, field types, search integration, and services for building and extending PHP-based content applications with a modular, API-driven architecture.
Both Legacy and Sql-Ng persistence abstractions are using Zeta Components Database component. This specification evaluates the possibility to replace Zeta Components Database with Doctrine DBAL.
Reasons for the evaluation are:
Zeta Components Database is used to abstract the following SQL concerns. These are hidden in implementations of database gateways and for Search in little helpers that generate the query parts.
Concerns that other separated parts handle:
The DBAL can cover the following current abstractions
Missing abstractions are:
Zeta Components Query API and Doctrine Query API for SELECTs are similar, allowing the opportunity to switch them in a simple way through a small compatibility abstraction for the Handler and Query APIs routine translation work.
The Update operations are a bit more cumbersome to change, because the parameter binding and type binding works so differently.
Refactoring steps:
Repeat for every gateway:
DBALException as well.Currently the aliasing/quoting code is pretty dominant in the Gateways, because of the way the ezc Query Objects work. Hiding this implementation detail behind a simple Table Gateway helps simplify the code a lot.
<?php
interface TableGateway
{
public function __construct(Connection $conn, TableMetadata $metadata);
public function insert(array $data);
public function update(array $data, array $where);
public function delete(array $where);
public function createSelectQuery();
public function createUpdateQuery();
public function createDeleteQuery();
public function createInsertQuery();
}
class TableMetadata
{
public $name;
public $sequenceName;
public $primaryKeys = array();
public $columns = array();
}
The first approach would require lots of tedious routine work to convert all APIs. Another approach would be not to use Doctrine's DBAL QueryBuilder, but use the Zeta Query API and write a new API-compatible implementation using Doctrine.
This would only require writing this API to instantly convert all gateways in both Legacy and Sql-Ng APIs.
Key is the introduction of an interface for the query objects and the handler:
<?php
interface DatabaseHandler
{
public function createSelectQuery();
public function createInsertQuery();
public function createUpdateQuery();
public function createDeleteQuery();
public function aliasedColumn( SelectQuery $query, $columnName, $tableName = null );
public function quoteColumn( $columnName, $tableName = null );
public function quoteTable( $tableName );
public function alias( $name, $alias );
public function quoteIdentifier( $identifier );
public function getAutoIncrementValue( $table, $column );
public function getSequenceName( $table, $column );
}
The Query objects have the same API that Zeta Database has, including
the expression object $q->expr->....
This can be translated to SQL executable by Doctrine DBAL.
How can I help you explore Laravel packages today?