PHP code example of zacharyrankin / named-sql-params
1. Go to this page and download the library: Download zacharyrankin/named-sql-params 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/ */
zacharyrankin / named-sql-params example snippets
$named = new NamedSqlParams;
$sql = <<<SQL
SELECT
id,
username,
email
FROM :!users_table
WHERE country = :country
AND gender IN (:genders)
SQL;
$params = [
'users_table' => 'users',
'country' => 'USA',
'genders' => ['M', 'F']
];
list($prepared_sql, $prepared_params) = $named->prep($sql, $params);
// $prepared_sql will be:
// SELECT
// id,
// username,
// email
// FROM users
// WHERE country = ?
// AND gender IN (?, ?)
// $prepared_params will be:
// ['USA', 'M', 'F']
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.