PHP code example of itrn0 / php-sql-interpolator

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

    

itrn0 / php-sql-interpolator example snippets


$interp = new SqlInterpolator();
$userId = 1002;
$query = <<<SQL
    SELECT * FROM users WHERE id = {$interp($userId)} 
        OR name IN ({$interp('Alice', 'Bob')})
SQL;
$params = $interp->getParams(); // { ":param_1" => 1002, ... }

// database query example
$db->query($query, $params);
bash
composer