Remove all nt from $wpdb->prepare()

Question

If I have a prepare method with a lot of fields like the one below, to make the code more usable and clear, I always separate the rules of my query with newlines, but if I have problems with these queries my log fills up with an infinity of tttttn making log analysis very difficult. The solution is to have the entire query in one unique line, or to filter with something like this

$sql = trim(preg_replace('/s+/', ' ', $sql));

is it possible to avoid to use this function? Maybe I’m missing something very basic…

$sql = $wpdb->prepare(
                        "SELECT
                            `progressivo`,
                            `data_fattura`,
                            `tipo`,
                            `piva`,
                            `cf`,
                            `ditta`,
                            `indirizzo`,
                            `citta`,
                            `nazione`,
                            `code`,
                            `nave`,
                            `data_partenza`,
                            `porto`,
                            `polizza`,
                            `targa`,
                            `diritti`,
                            `totale`,
                            `pagamento`,
                            `data_pagamento`,
                            `garante`
                        FROM $tablename
                        WHERE
                        `progressivo` LIKE %s
                        OR
                        `progressivo` BETWEEN %d AND %d
                        ORDER BY `data_fattura`
                        DESC LIMIT %d, %d",
                        $_POST['search-id-dal'] == '' ? '%' : $_POST['search-id-dal'],
                        $_POST['search-id-dal'],
                        $_POST['search-id-al'],
                        $_POST['start'],
                        $_POST['length']
                        );
0
silvered.dragon 2 months 0 Answers 15 views 0

Leave an answer