PHP code example of lukafurlan / php-query-builder

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

    

lukafurlan / php-query-builder example snippets

 
define('MYSQL_HOST', 'localhost');
define('MYSQL_DATABASE', 'database');
define('MYSQL_USERNAME', 'root');
define('MYSQL_PASSWORD', 'password');
 
$queryManager = new DMLQueryManager();
 
$queryManager->select()
    ->columns(["id"])
    ->from("users")
    ->where(["country = :country"])
    ->bind([":country" => "Slovenia"])
    ->execute();
 
$queryManager->insert()
    ->into("users")
    ->columns(["name", "country"])
    ->values([
        ["Luka", "Slovenia"],
        ["John", "England"]
    ])
    ->execute();
 
$queryManager->update()
    ->table("users")
    ->columns([
        "country" => "Germany"
    ])
    ->where(["country = :country"])
    ->bind([":country" => "England"])
    ->execute();
 
$queryManager->delete()
    ->from("users")
    ->where(["country = :country"])
    ->bind([":country" => "England"])
    ->execute();

$ composer