public static function getSqlWithParams(string $sql, array $params = []): string
    {
        if (! empty($params)) {
            $indexed = ($params === array_values($params));
            foreach ($params as $k => $v) {
                if (is_string($v)) {
                    $v = "'${v}'";
                }
                if (is_array($v)) {
                    $v = "'" . implode("','", $v) . "'";
                }
                if ($indexed) {
                    $sql = preg_replace('/\?/', $v, $sql, 1);
                } else {
                    $sql = str_replace(":${k}", $v, $sql);
                }
            }
        }

        return str_replace(PHP_EOL, '', $sql);
    }
public static function getSqlWithParams(string $sql, array $params = []): string
    {
        if (! empty($params)) {
            $indexed = ($params === array_values($params));
            foreach ($params as $k => $v) {
                if (is_string($v)) {
                    $v = "'${v}'";
                }
                if (is_array($v)) {
                    $v = "'" . implode("','", $v) . "'";
                }
                if ($indexed) {
                    $sql = preg_replace('/\?/', $v, $sql, 1);
                } else {
                    $sql = str_replace(":${k}", $v, $sql);
                }
            }
        }

        return str_replace(PHP_EOL, '', $sql);
    }
public static function getSqlWithParams ( string $ sql , array $ params = [ ] ) : string { if ( ! empty ( $ params ) ) { $ indexed = ( $ params === array_values ( $ params ) ) ; foreach ( $ params as $ k => $ v ) { if ( is_string ( $ v ) ) { $ v = "'${v}'" ; } if ( is_array ( $ v ) ) { $ v = "'" . implode ( "','" , $ v ) . "'" ; } if ( $ indexed ) { $ sql = preg_replace ( '/\?/' , $ v , $ sql , 1 ) ; } else { $ sql = str_replace ( ":${k}" , $ v , $ sql ) ; } } } return str_replace ( PHP_EOL , '' , $ sql ) ; }
get query with parameters in it
get query with parameters in it