protected function tweak_param_names($sql, array $params) {
        if (empty($params)) {
            return array($sql, $params);
        }

        $newparams = array();
        $searcharr = array(); // search => replace pairs
        foreach ($params as $name => $value) {
            // Keep the name within the 30 chars limit always (prefixing/replacing)
            if (strlen($name) <= 28) {
                $newname = 'o_' . $name;
            } else {
                $newname = 'o_' . substr($name, 2);
            }
            $newparams[$newname] = $value;
            $searcharr[':' . $name] = ':' . $newname;
        }
        // sort by length desc to avoid potential str_replace() overlap
        uksort($searcharr, array('oci_native_moodle_database', 'compare_by_length_desc'));

        $sql = str_replace(array_keys($searcharr), $searcharr, $sql);
        return array($sql, $newparams);
    }
protected function tweak_param_names($sql, array $params) {
        if (empty($params)) {
            return array($sql, $params);
        }

        $newparams = array();
        $searcharr = array(); // search => replace pairs
        foreach ($params as $name => $value) {
            // Keep the name within the 30 chars limit always (prefixing/replacing)
            if (strlen($name) <= 28) {
                $newname = 'o_' . $name;
            } else {
                $newname = 'o_' . substr($name, 2);
            }
            $newparams[$newname] = $value;
            $searcharr[':' . $name] = ':' . $newname;
        }
        // sort by length desc to avoid potential str_replace() overlap
        uksort($searcharr, array('oci_native_moodle_database', 'compare_by_length_desc'));

        $sql = str_replace(array_keys($searcharr), $searcharr, $sql);
        return array($sql, $newparams);
    }
protected function tweak_param_names ( $ sql , array $ params ) { if ( empty ( $ params ) ) { return array ( $ sql , $ params ) ; } $ newparams = array ( ) ; $ searcharr = array ( ) ; // search => replace pairs foreach ( $ params as $ name => $ value ) { // Keep the name within the 30 chars limit always (prefixing/replacing) if ( strlen ( $ name ) <= 28 ) { $ newname = 'o_' . $ name ; } else { $ newname = 'o_' . substr ( $ name , 2 ) ; } $ newparams [ $ newname ] = $ value ; $ searcharr [ ':' . $ name ] = ':' . $ newname ; } // sort by length desc to avoid potential str_replace() overlap uksort ( $ searcharr , array ( 'oci_native_moodle_database' , 'compare_by_length_desc' ) ) ; $ sql = str_replace ( array_keys ( $ searcharr ) , $ searcharr , $ sql ) ; return array ( $ sql , $ newparams ) ; }
Make sure there are no reserved words in param names...
@param string $sql
@param array $params
@return array ($sql, $params) updated query and parameters
Make sure there are no reserved words in param names ...