PHP code example of tsukasa / query_builder

1. Go to this page and download the library: Download tsukasa/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/ */

    

tsukasa / query_builder example snippets


use Tsukasa\QueryBuilder\QueryBuilder

ction([
        'dbname' => 'mydb',
        'user' => 'user',
        'password' => 'secret',
        'host' => 'localhost',
        'driver' => 'pdo_mysql',
    ], 
    $config = new \Doctrine\DBAL\Configuration()
);


$qb = QueryBuilder::getInstance($connection);
$qb->setTypeSelect()
    ->setSelect('*')
    ->setFrom('comment')
    ->setWhere(['id__gte' => 1])
    ->setOrder(['created_at']);

$connection->fetchAll($qb->toSQL());
// SELECT * FROM comment WHERE id >= 1 ORDER BY created_at ASC