2017 © Pedro Peláez
 

contao-module contao-query-builder

Contao query builder based on Aura/SQL_Query

image

netzmacht/contao-query-builder

Contao query builder based on Aura/SQL_Query

  • Wednesday, January 20, 2016
  • by netzmacht
  • Repository
  • 1 Watchers
  • 0 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Contao Query builder

Build Status Version License Downloads Contao Community Alliance coding standard, (*1)

This extension provides a query builder based on the aura/sqlquery., (*2)

Install

You can install this library using Composer. It requires at least PHP 5.5 and Contao 3.2., (*3)

$ php composer.phar require netzmacht/contao-query-builder:~1.0

Documentation

Please refer to the aura/sqlquery documentation to understand the basic usage., (*4)

The Contao integration adds easy execution of the created statements and DI integration using c-c-a/dependency-container., (*5)

Basic usage, (*6)

<?php

$factory = $GLOBALS['container']['query-builder.factory'];

// Creates insert query implementing interface Netzmacht\Contao\QueryBuilder\Query\Insert
$insert  = $factory->newInsert();

// Creates insert query implementing interface Netzmacht\Contao\QueryBuilder\Query\Update
$update  = $factory->newUpdate();

// Creates insert query implementing interface Netzmacht\Contao\QueryBuilder\Query\Select
$select  = $factory->newSelect();

// Creates insert query implementing interface Netzmacht\Contao\QueryBuilder\Query\Delete
$delete  = $factory->newDelete();

// Executing the statement
$result = $statement->execute();

Extended features

Though this extension is based on aura/sqlquery it provides some extra features., (*7)

Query conditions, (*8)

If you have complex where conditions you can pass an callback which generates a separate condition object., (*9)

<?php

// Generates "category = 2 AND (date > ? OR highlighted = 1)"
$query
    ->where('category = 2')
    ->where(
        function (Netzmacht\Contao\QueryBuilder\Condition $condition) {
            $condition->orWhere('date > ?', time());
            $condition->orWhere('highlighted = 1');
        }
    );

Where in statements, (*10)

As Contao does not use PDO as driver you have to manually create whereIn statements. So that whereIn and orWhereIn are provided for queries and for the conditions., (*11)

<?php

// Generates "category = 2 AND (date > ? OR highlighted = 1)"
$query
    ->whereIn('category', [2, 3])
    ->whereIn('author', [3, 4, 2]);

Differences

Though you can use named bind values the generated statement does only contain ? placeholders as Contao only support these., (*12)

The Versions

20/01 2016

dev-master

9999999-dev

Contao query builder based on Aura/SQL_Query

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database sql query contao builder

20/01 2016

dev-develop

dev-develop

Contao query builder based on Aura/SQL_Query

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database sql query contao builder

20/01 2016

1.0.0-rc1

1.0.0.0-RC1

Contao query builder based on Aura/SQL_Query

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database sql query contao builder