2017 © Pedro Peláez
 

library dbal-manager

Helper classes for Doctrine DBAL

image

jarjak/dbal-manager

Helper classes for Doctrine DBAL

  • Thursday, May 4, 2017
  • by JarJak
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,958 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 8 Versions
  • 4 % Grown

The README.md

DBALManager

SensioLabsInsight Build Status, (*1)

Set of helper classes for Doctrine DBAL. It has been made maily to ease creating bulk imports. It provides a method to execute INSERT ... ON DUPLICATE KEY UPDATE query on MySQL-compatible databases, which is what I miss in Doctrine's MySQL driver., (*2)

Symfony installation

To use this class in Symfony 2/3, please look at DBALManagerBundle., (*3)

In Symfony 4, thanks to autowiring you are not forced to use a bundle, just add these lines in your services.yaml:, (*4)

services:
    _defaults:
        autowire: true

    JarJak\DBALManager: ~

Integration with other frameworks

Run:, (*5)

composer require jarjak/dbal-manager

The class is PSR-0/PSR-4 compatible, so it can be integrated easily with any modern framework. Here is an example for Silex:, (*6)

//Application.php

$app['dbal_manager'] = $app->share(function ($app) {
    $manager = new JarJak\DBALManager($app['db']);
    return $manager;
});

Simple example:

You want to insert data or update them if row already exists., (*7)

$sqlArray = [
    'id' => 1,
    'username' => 'JohnKennedy',
    'email' => 'john@kennedy.gov'
];

/* @var $manager JarJak\DBALManager */
$manager->insertOrUpdate('user', $sqlArray);

Or you want to just skip this row if it exists:, (*8)

$manager->insertIgnore('user', $sqlArray);

Advanced example:

Lets say we have user table with: - unique usernames and emails - column active can contain only 0 or 1 (not nullable) - column address can be null, (*9)

$sqlArray = [
    'username' => 'JohnKennedy',
    'email' => 'john@kennedy.gov',
    'password' => $password,
    'address' => '',
    'active' => 0,
];

/* @var $manager JarJak\DBALManager */
$manager->insertOrUpdate('user', $sqlArray, 2, ['active']);

Dumping Queries

DBALManager can use VarDumper to dump SQL queries from QueryBuilder ready to be copypasted into database server (with parameters already included)., (*10)

/* @var QueryBuilder $queryBuilder */
\JarJak\SqlDumper::dumpQuery($queryBuilder);

If you don't use QueryBuilder you can still dump parametrized SQL with:, (*11)

\JarJak\SqlDumper::dumpSql($sql, $params);

Testing

Run tests with:, (*12)

composer run-script test

Fix code style with:, (*13)

composer run-script csfix

The Versions

04/05 2017

dev-master

9999999-dev https://github.com/JarJak/DBALManager

Helper classes for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

17/03 2017

dev-multiinsert-returnasarray

dev-multiinsert-returnasarray https://github.com/JarJak/DBALManager

Helper classes for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

09/03 2017

2.0.0

2.0.0.0 https://github.com/JarJak/DBALManager

Helper classes for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

09/03 2017

dev-dumping-improvements

dev-dumping-improvements https://github.com/JarJak/DBALManager

Helper classes for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

17/10 2016

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/JarJak/DBALManager

Helper class for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

17/10 2016

1.1.0

1.1.0.0 https://github.com/JarJak/DBALManager

Helper class for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

04/02 2016

1.0.1

1.0.1.0 https://github.com/JarJak/DBALManager

Helper class for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject

03/09 2015

1.0

1.0.0.0 https://github.com/JarJak/DBALManager

Helper class for Doctrine DBAL

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Jarek Jakubowski

database dbal persistence queryobject