src/xPDO/xPDO.php
public function parseBindings($sql, $bindings) {
        if (!empty($sql) && !empty($bindings)) {
            $bound = array();
            foreach ($bindings as $k => $param) {
                if (!is_array($param)) {
                    $v= $param;
                    $type= $this->getPDOType($param);
                    $bindings[$k]= array(
                        'value' => $v,
                        'type' => $type
                    );
                } else {
                    $v= $param['value'];
                    $type= $param['type'];
                }
                if (!$v) {
                    switch ($type) {
                        case \PDO::PARAM_INT:
                            $v= '0';
                            break;
                        case \PDO::PARAM_BOOL:
                            $v= '0';
                            break;
                        default:
                            break;
                    }
                }
                if ($type > 0) {
                    $v= $this->quote($v, $type);
                } else {
                    $v= 'NULL';
                }
                if (!is_int($k) || substr($k, 0, 1) === ':') {
                    $pattern= '/' . $k . '\b/';
                    $bound[$pattern] = str_replace(array('\\', '$'), array('\\\\', '\$'), $v);
                } else {
                    $pattern = '/(\?)(\b)?/';
                    $sql = preg_replace($pattern, ':' . $k . '$2', $sql, 1);
                    $bound['/:' . $k . '\b/'] = str_replace(array('\\', '$'), array('\\\\', '\$'), $v);
                }
            }
            if ($this->getDebug() === true) {
                $this->log(xPDO::LOG_LEVEL_DEBUG, "{$sql}\n" . print_r($bound, true));
            }
            if (!empty($bound)) {
                $sql= preg_replace(array_keys($bound), array_values($bound), $sql);
            }
        }
        return $sql;
    }
public function parseBindings($sql, $bindings) {
        if (!empty($sql) && !empty($bindings)) {
            $bound = array();
            foreach ($bindings as $k => $param) {
                if (!is_array($param)) {
                    $v= $param;
                    $type= $this->getPDOType($param);
                    $bindings[$k]= array(
                        'value' => $v,
                        'type' => $type
                    );
                } else {
                    $v= $param['value'];
                    $type= $param['type'];
                }
                if (!$v) {
                    switch ($type) {
                        case \PDO::PARAM_INT:
                            $v= '0';
                            break;
                        case \PDO::PARAM_BOOL:
                            $v= '0';
                            break;
                        default:
                            break;
                    }
                }
                if ($type > 0) {
                    $v= $this->quote($v, $type);
                } else {
                    $v= 'NULL';
                }
                if (!is_int($k) || substr($k, 0, 1) === ':') {
                    $pattern= '/' . $k . '\b/';
                    $bound[$pattern] = str_replace(array('\\', '$'), array('\\\\', '\$'), $v);
                } else {
                    $pattern = '/(\?)(\b)?/';
                    $sql = preg_replace($pattern, ':' . $k . '$2', $sql, 1);
                    $bound['/:' . $k . '\b/'] = str_replace(array('\\', '$'), array('\\\\', '\$'), $v);
                }
            }
            if ($this->getDebug() === true) {
                $this->log(xPDO::LOG_LEVEL_DEBUG, "{$sql}\n" . print_r($bound, true));
            }
            if (!empty($bound)) {
                $sql= preg_replace(array_keys($bound), array_values($bound), $sql);
            }
        }
        return $sql;
    }
public function parseBindings ( $ sql , $ bindings ) { if ( ! empty ( $ sql ) && ! empty ( $ bindings ) ) { $ bound = array ( ) ; foreach ( $ bindings as $ k => $ param ) { if ( ! is_array ( $ param ) ) { $ v = $ param ; $ type = $ this -> getPDOType ( $ param ) ; $ bindings [ $ k ] = array ( 'value' => $ v , 'type' => $ type ) ; } else { $ v = $ param [ 'value' ] ; $ type = $ param [ 'type' ] ; } if ( ! $ v ) { switch ( $ type ) { case \ PDO :: PARAM_INT : $ v = '0' ; break ; case \ PDO :: PARAM_BOOL : $ v = '0' ; break ; default : break ; } } if ( $ type > 0 ) { $ v = $ this -> quote ( $ v , $ type ) ; } else { $ v = 'NULL' ; } if ( ! is_int ( $ k ) || substr ( $ k , 0 , 1 ) === ':' ) { $ pattern = '/' . $ k . '\b/' ; $ bound [ $ pattern ] = str_replace ( array ( '\\' , '$' ) , array ( '\\\\' , '\$' ) , $ v ) ; } else { $ pattern = '/(\?)(\b)?/' ; $ sql = preg_replace ( $ pattern , ':' . $ k . '$2' , $ sql , 1 ) ; $ bound [ '/:' . $ k . '\b/' ] = str_replace ( array ( '\\' , '$' ) , array ( '\\\\' , '\$' ) , $ v ) ; } } if ( $ this -> getDebug ( ) === true ) { $ this -> log ( xPDO :: LOG_LEVEL_DEBUG , "{$sql}\n" . print_r ( $ bound , true ) ) ; } if ( ! empty ( $ bound ) ) { $ sql = preg_replace ( array_keys ( $ bound ) , array_values ( $ bound ) , $ sql ) ; } } return $ sql ; }
Parses parameter bindings in SQL prepared statements.

@param string $sql A SQL prepared statement to parse bindings in.
@param array $bindings An array of parameter bindings to use for the replacements.
@return string The SQL with the binding placeholders replaced.
Parses parameter bindings in SQL prepared statements .