2017 © Pedro Peláez
 

library doctrineviewsbundle

Generate MySQL views with Doctrine

image

mte/doctrineviewsbundle

Generate MySQL views with Doctrine

  • Sunday, February 4, 2018
  • by mrk-te
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MteDoctrineViewsBundle

Converts a Doctrine\ORM\Query in a Doctrine\DBAL\Schema\View., (*1)

Provides a manager class to convert, create, and the views., (*2)

Configuration

mte_doctrine_views:
    dbal:

        # Example:
        default:             database_connection

        # Prototype
        name:                 ~

Generates a service "mte.doctrine_views.manager.default" associated to the DBAL service "database_connection", (*3)

Information for Service "mte.doctrine_views.manager.default"
============================================================

 ---------------- ---------------------------------------------------
  Option           Value
 ---------------- ---------------------------------------------------
  Service ID       mte.doctrine_views.manager.default
  Class            Mte\DoctrineViewsBundle\Doctrine\View\ViewManager
  Tags             -
  Public           yes
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- ---------------------------------------------------

Usage

Get the Doctrine Query Builder query :, (*4)

class UserRepository extends ServiceEntityRepository
{
    public function createUserViewQuery()
    {
        $qb     = $this->createQueryBuilder('u');

        return $qb->select('u.id')
            ->addSelect('CONCAT(u.username, \'@\', d.name) AS user')
            ->addSelect('u.password')
            ->join('u.domain', 'd')
            ->where('u.enabled = true')
            ->andWhere('d.enabled = true')
            ->getQuery();
    }
}

Use the manager to handle your view, (*5)

/**
 * @var App\Repository\UserRepository $userRepository
 */
$query  = $userRepository->createUserViewQuery();

/**
 * Converts the Doctrine\ORM\Query $query in Doctrine\DBAL\Schema\View
 * @var Mte\DoctrineViewsBundle\Doctrine\View\ViewManager $viewManager
 * @see #Configuration
 */
$view   = $viewManager->getViewFromQuery('my_user_view', $query);

/**
 * Creates the given view
 */
$viewManager->createView($view)

/**
 * Drops the given View if exists
 * Creates the given view
 */
$viewManager->dropAndCreateView($view)

/**
 * Converts the Doctrine\ORM\Query $query in Doctrine\DBAL\Schema\View
 * Creates the given view
 */
$viewManager->createViewFromQuery('my_user_view', $query)

/**
 * Converts the Doctrine\ORM\Query $query in Doctrine\DBAL\Schema\View
 * Drops the given View if exists
 * Creates the given view
 */
$viewManager->dropAndCreateViewFromQuery(string $name, Query $query)

The Versions

04/02 2018

dev-master

9999999-dev https://github.com/mrk-te/DoctrineViewsBundle

Generate MySQL views with Doctrine

  Sources   Download

GPL-2.0-or-later

The Requires

 

database doctrine symfony mysql views