PHP code example of neoparla / dbescaper

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

    

neoparla / dbescaper example snippets


$value = "string with quotes (') and slashes (\)";
DbStatement->bindParam(':binding', $value, Binding::String);
// Real query: 'string with quotes (\') and slashes (\\)'

$value = "field_name";
DbStatement->bindParam(':binding', $value, Binding::Field);
// Real query: `field_name`

$value = new DbTuple(Binding::PARAM_STRING, array('string 1', 'string 2'), DbTuple::WITH_PARENTHESIS);;
DbStatement->bindParam(':binding', $value, Binding::Tuple);
// Real query: ( 'string 1', 'string 2' )

$db_escaper = DbEscaper::init(
    array(
        'host' => 'host',
        'user'  => 'user',
        'pass'  => 'pass',
        'schema'    => 'schema',
        // 'port' => 3306
    )
);