2017 © Pedro Peláez
 

symfony-bundle yesql-bundle

Yesql Bundle for Symfony

image

olimsaidov/yesql-bundle

Yesql Bundle for Symfony

  • Tuesday, January 16, 2018
  • by olimsaidov
  • Repository
  • 1 Watchers
  • 3 Stars
  • 306 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*1)

$ composer require olimsaidov/yesql-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*2)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*3)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Ox\YesqlBundle\YesqlBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Configure the Bundle

Then, configure the bundle by adding the following lines in the app/config/config.yml file of your project:, (*4)

yesql:
  connection: default # optional, doctrine custom connection name
  services:
    -
      path: "%kernel.root_dir%/../src/Acme/BlogBundle/Resources/blog.sql" # path to sql file
      name: "blog" # service name

Each query in your SQL file must be commented like this:, (*5)

-- name: getAllPosts*
-- This will fetch all rows from posts
select * from posts;

-- name: getPostById
--
select * from posts where id = ?;

-- name: insertPost
-- You can use parametrized placeholder
insert into post (title, body) values (:title, :body);

Query name must end with * symbol to query multiple rows., (*6)

Step 4: Use the Bundle

Execute your queries by calling the service:, (*7)

$this->get('yesql.blog')->getAllPosts(); // returns all posts as array

$this->get('yesql.blog')->getPostById(3); // returns single post

$this->get('yesql.blog')->insertPost([':title' => 'Hello', ':body' => 'World']); // returns last insert id

The Versions

16/01 2018

dev-master

9999999-dev

Yesql Bundle for Symfony

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Olim Saidov

database sql doctrine symfony yesql