use double quotes to compose SQL requests

This commit is contained in:
Thomas Negre 2022-03-09 09:34:50 +01:00
parent 93765add38
commit 7f527b85b0
2 changed files with 8 additions and 8 deletions

View File

@ -5138,11 +5138,11 @@ class Facture extends CommonInvoice
public function willBeLastOfSameType()
{
// get date of last validated invoices of same type
$sql = 'SELECT datef';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE type = ' . (int) $this->type ;
$sql .= ' AND date_valid IS NOT NULL';
$sql .= ' ORDER BY datef DESC LIMIT 1';
$sql = "SELECT datef";
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE type = " . (int) $this->type ;
$sql .= " AND date_valid IS NOT NULL";
$sql .= " ORDER BY datef DESC LIMIT 1";
$result = $this->db->query($sql);
if ($result) {

View File

@ -1212,9 +1212,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
if ($objecttmp->element == 'facture') {
if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
// order $toselect by date
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $toselect)).')';
$sql .= ' ORDER BY datef';
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE rowid IN (".$db->sanitize(implode(",", $toselect)).")";
$sql .= " ORDER BY datef";
$resql = $db->query($sql);
if ($resql) {