private function rewrite()
    {
        // Current positional parameter.
        $positionalParameter = 1;

        // TRUE if we are in a literal section else FALSE.
        $literal = false;

        // The statement length.
        $statementLength = strlen($this->statement);

        // Iterate each statement char.
        for ($placeholderPos = 0; $placeholderPos < $statementLength; $placeholderPos++) {

            // Switch the literal flag if the current statement char is a literal delimiter.
            if (in_array($this->statement[$placeholderPos], array('\'', '"'))) {
                $literal = !$literal;
            }

            // Check if we are not in a literal section and the current statement char is a double colon.
            if (!$literal && $this->statement[$placeholderPos] === ':') {

                // Determine placeholder length.
                $placeholderLength = 1;
                while (isset($this->statement[$placeholderPos + $placeholderLength])
                    && $this->isValidPlaceholderCharacter($this->statement[$placeholderPos + $placeholderLength])) {
                    $placeholderLength++;
                }

                // Extract placeholder from the statement.
                $placeholder = substr($this->statement, $placeholderPos, $placeholderLength);

                // Initialize rewrites parameters.
                if (!isset($this->parameters[$placeholder])) {
                    $this->parameters[$placeholder] = array();
                }

                // Rewrites parameter.
                $this->parameters[$placeholder][] = $positionalParameter;

                // Rewrite statement.
                $this->statement = substr($this->statement, 0, $placeholderPos).
                    '?'.
                    substr($this->statement, $placeholderPos + $placeholderLength);

                // Decrement statement length.
                $statementLength = $statementLength - $placeholderLength + 1;

                // Increment position parameter.
                $positionalParameter++;
            }
        }
    }
private function rewrite()
    {
        // Current positional parameter.
        $positionalParameter = 1;

        // TRUE if we are in a literal section else FALSE.
        $literal = false;

        // The statement length.
        $statementLength = strlen($this->statement);

        // Iterate each statement char.
        for ($placeholderPos = 0; $placeholderPos < $statementLength; $placeholderPos++) {

            // Switch the literal flag if the current statement char is a literal delimiter.
            if (in_array($this->statement[$placeholderPos], array('\'', '"'))) {
                $literal = !$literal;
            }

            // Check if we are not in a literal section and the current statement char is a double colon.
            if (!$literal && $this->statement[$placeholderPos] === ':') {

                // Determine placeholder length.
                $placeholderLength = 1;
                while (isset($this->statement[$placeholderPos + $placeholderLength])
                    && $this->isValidPlaceholderCharacter($this->statement[$placeholderPos + $placeholderLength])) {
                    $placeholderLength++;
                }

                // Extract placeholder from the statement.
                $placeholder = substr($this->statement, $placeholderPos, $placeholderLength);

                // Initialize rewrites parameters.
                if (!isset($this->parameters[$placeholder])) {
                    $this->parameters[$placeholder] = array();
                }

                // Rewrites parameter.
                $this->parameters[$placeholder][] = $positionalParameter;

                // Rewrite statement.
                $this->statement = substr($this->statement, 0, $placeholderPos).
                    '?'.
                    substr($this->statement, $placeholderPos + $placeholderLength);

                // Decrement statement length.
                $statementLength = $statementLength - $placeholderLength + 1;

                // Increment position parameter.
                $positionalParameter++;
            }
        }
    }
private function rewrite ( ) { // Current positional parameter. $ positionalParameter = 1 ; // TRUE if we are in a literal section else FALSE. $ literal = false ; // The statement length. $ statementLength = strlen ( $ this -> statement ) ; // Iterate each statement char. for ( $ placeholderPos = 0 ; $ placeholderPos < $ statementLength ; $ placeholderPos ++ ) { // Switch the literal flag if the current statement char is a literal delimiter. if ( in_array ( $ this -> statement [ $ placeholderPos ] , array ( '\'' , '"' ) ) ) { $ literal = ! $ literal ; } // Check if we are not in a literal section and the current statement char is a double colon. if ( ! $ literal && $ this -> statement [ $ placeholderPos ] === ':' ) { // Determine placeholder length. $ placeholderLength = 1 ; while ( isset ( $ this -> statement [ $ placeholderPos + $ placeholderLength ] ) && $ this -> isValidPlaceholderCharacter ( $ this -> statement [ $ placeholderPos + $ placeholderLength ] ) ) { $ placeholderLength ++ ; } // Extract placeholder from the statement. $ placeholder = substr ( $ this -> statement , $ placeholderPos , $ placeholderLength ) ; // Initialize rewrites parameters. if ( ! isset ( $ this -> parameters [ $ placeholder ] ) ) { $ this -> parameters [ $ placeholder ] = array ( ) ; } // Rewrites parameter. $ this -> parameters [ $ placeholder ] [ ] = $ positionalParameter ; // Rewrite statement. $ this -> statement = substr ( $ this -> statement , 0 , $ placeholderPos ) . '?' . substr ( $ this -> statement , $ placeholderPos + $ placeholderLength ) ; // Decrement statement length. $ statementLength = $ statementLength - $ placeholderLength + 1 ; // Increment position parameter. $ positionalParameter ++ ; } } }
Rewrite the named statement and parameters to positional.

Example:
- before:
- statement: SELECT * FROM foo WHERE bar = :bar
- parameters: array()
- after:
- statement: SELECT * FROM foo WHERE bar = ?
- parameters: array(':bar' => array(1))
Rewrite the named statement and parameters to positional .