Named parameters in sql strings
$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']
- More documentation
- Refactor code some more
- Push to packagist