PHP code example of netzmacht / contao-query-builder

1. Go to this page and download the library: Download netzmacht/contao-query-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

netzmacht / contao-query-builder example snippets




$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();




// 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');
        }
    );




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

$ php composer.phar