Download the PHP package vladshut/dbal-gateway without Composer

On this page you can find all versions of the php package vladshut/dbal-gateway. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbal-gateway

DBALGateway - Table Gateway for Doctrine DBAL.

Build Status

Doctrine DBAL is a fantastic extension to PDO but writing CRUD code for simple 1 to 1 mappings still represents a time sink. This component implements Table Gateway on top of Doctrine DBAL and is heavily inspired by zf2 Table Gateway.

What are the benefits?

  1. Using metadata the gateway will convert values, for example DateTime is converted to a stamps and the stamp is converted back to DateTime.
  2. Events system, e.g pre_select , post_delete , pre_insert... based around the symfony2 event dispatcher.
  3. Query Logger using Monolog, you would normally write this yourself.
  4. Builder can map records to entities, you could build an active record on top of this gateway.
  5. Supply a collection class and it will load them into it.
  6. Fluid interface for running selects, inserts, updates and deletes.
  7. Faster than manual CRUD.

Whats are the cons?

  1. Loose auto-completion in your IDE, for subclasses, only get it for the bases classes.
  2. Overhead a little more memory and extra method calls.

Install

This component can be installed via composer.

Usage.

There are 3 components to every table.

  1. Metadata instanceof DBALGateway\Metadata\Table.
  2. Subclass of DBALGateway\Table\AbstractTable the gateway.
  3. Subclass of DBALGateway\Query\AbstractQuery the query class.

There are 2 optional components to every table

  1. Custom result-set implementation of Doctrine\Common\Collections\Collection.
  2. Entity builder implementation of DBALGateway\Builder\BuilderInterface.

1. The Metadata

Assume have the following databse table.

You can declare the metadata as follows.

The datatypes (second argument in addColumn) are not mysql types but doctrine types, the mapping can be found under Doctrine\DBAL\Platforms\{MYPLATFORM}.

2. The Table Gateway.

You will need to declare a subclass of DBALGateway\Metadata\Table and override the method newQueryObject().

You may also include other custom code on this class. But note all methods a marked as protected be careful with naming.

3. The QueryClass

You will need to subclass DBALGateway\Query\AbstractQuery which is itself a subclass of Doctrine\DBAL\Query\QueryBuilder.

Each custom filter should do the following.

  1. Set a unique named parameter.
  2. Set the parameter value and fetch the doctrine type from the meta-data in the table gateway.
  3. Return $this.

4. The Collections class.

When using find() on the gateway results will be stored in a collection class offerd by doctrine Doctrine\Common\Collections\ArrayCollection. If the gateway's constructor is passed an instance an alternative that inherits the interface from Doctrine\Common\Collections\Collection it will clone a copy and use that.

This gateway will clone $collection on each call to find. Note: findOne() does not return collection just entity/array.

5. The Entity Builder

When using find() or findOne() each result found in the set will be passed to the builder for conversion into an entity. A builder must implement the interface found at DBALGateway\Builder\BuilderInterface.

Note: If a collection class is used this new entity will be given to the collection.

Running Queries

Run an INSERT Query.

Run an UPDATE Query.

Run a DELETE Query.

Run a SELECT Query.

There are two methods findOne() and find().

Instance a Gateway?

A Gateway has the following dependecies.

  1. The table name in the schema.
  2. The Doctrine\DBAL\Connection $connection.
  3. An instance of Symfony\Component\EventDispatcher\EventDispatcherInterface.
  4. The meta data for table instance of DBALGateway\Metadata\Table.
  5. (optional) a result-set to clone an instance class that implements Doctrine\Common\Collections\Collection
  6. (optional) a enity builder an instance class that implements DBALGateway\Builder\BuilderInterface

Features and Events.

The Gateway emits a number of events.

Event Name Event Description
pre_initilize Occurs during object construction.
post_initilize Occurs after object construction.
pre_select Occurs before a select query is run.
post_select Occurs after a select query is run.
pre_delete Occurs before delete query is run.
post_delete Occurs after delete query is run.
pre_insert Occurs before an insert is run.
post_insert Occurs after an insert is run.
pre_update Occurs before an update is run.
post_update Occurs after an update is run.

For an example see the BufferedQueryLogger.


All versions of dbal-gateway with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-pdo Version *
symfony/event-dispatcher Version ~3.4|~4.0
doctrine/dbal Version ^2.8
doctrine/collections Version ^1.5
monolog/monolog Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vladshut/dbal-gateway contains the following files

Loading the files please wait ....