PHP code example of aviat / query

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

    

aviat / query example snippets




$params = array(
	'type' => 'mysql', // mysql, pgsql, sqlite
	'host' => 'localhost', // address or socket
	'user' => 'root',
	'pass' => '',
	'port' => '3306',
	'database' => 'test_db',

	// Only 


Query()->get('table_name');

// or
$result = Query()->query($sql);



// Set the alias in the connection parameters
$params['alias'] = 'old';

// Connect to the legacy database
Query('old')->query($sql);


$query = $db->select('id, key as k, val')
	->from('table t')
	->where('k >', 3)
	->orWhere('id !=', 5)
	->orderBy('val', 'DESC')
	->limit(3, 1)
	->get();


$query = $db->get('table_name');

$results = $query->fetchAll(PDO::FETCH_ASSOC);


$query = $db->set('foo', 'bar')
	->set('foobar', 'baz')
	->where('foo !=', 'bar')
	->insert('table');


$query = $db->set('foo', 'bar')
	->set('foobar', 'baz')
	->where('foo !=', 'bar')
	->update('table');