Skip to content

zeroSal/php-safe-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-safe-builder

PHP safe string builder. Builds SQL query.

builder

Icon by Freepik - Flaticon

Why this library?

PHP does not provide the capability to securely build SQL strings statically. One would need to rely on PDO or MySQLi, but what if there isn't a database to connect to and you just need to construct an escaped query?

An example use case: constructing an SQL string to be executed via STDIN in a mysql client on a remote server via SSH.

Usage

# Instantiate the object
$sqlBuilder = new SqlBuilder();

# Write the query template
$query = 'SELECT * FROM this_table WHERE this_field = :value AND other_field = :value2';

# Safely build the query
$safeQuery = $sqlBuilder->build($query, [
':value' => 'This is a value',
':value2' => 123
]);

About

PHP safe string builder. Builds SQL query.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages