diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php
index 8b94959a43c..77c20325a9d 100644
--- a/htdocs/debugbar/class/TraceableDB.php
+++ b/htdocs/debugbar/class/TraceableDB.php
@@ -46,7 +46,7 @@ class TraceableDB extends DoliDB
public function __construct($db)
{
$this->db = $db;
- $this->type = $db->type;
+ $this->type = $this->db->type;
$this->queries = array();
}
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php
index bf78a051d83..f686309f63c 100644
--- a/htdocs/don/admin/donation.php
+++ b/htdocs/don/admin/donation.php
@@ -196,7 +196,7 @@ $type = 'donation';
$def = array();
$sql = "SELECT nom";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
-$sql .= " WHERE type = '".$type."'";
+$sql .= " WHERE type = '".$db->escape($type)."'";
$resql = $db->query($sql);
if ($resql)
{
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index bb800b81fc2..c3cb0e5462b 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -242,7 +242,7 @@ class EcmFiles extends CommonObject
$sql .= 'src_object_type,';
$sql .= 'src_object_id';
$sql .= ') VALUES (';
- $sql .= " '".$ref."', ";
+ $sql .= " '".$this->db->escape($ref)."', ";
$sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").',';
$sql .= ' '.(!isset($this->share) ? 'NULL' : "'".$this->db->escape($this->share)."'").',';
$sql .= ' '.$this->entity.',';
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 8db2eac723e..9b6a07a5435 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -702,7 +702,7 @@ class Expedition extends CommonObject
// Validate
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
- $sql .= " ref='".$numref."'";
+ $sql .= " ref='".$this->db->escape($numref)."'";
$sql .= ", fk_statut = 1";
$sql .= ", date_valid = '".$this->db->idate($now)."'";
$sql .= ", fk_user_valid = ".$user->id;
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 8770a0ab1a2..610e749da16 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -461,7 +461,7 @@ class ExpenseReport extends CommonObject
$sql .= " , date_fin = '".$this->db->idate($this->date_fin)."'";
if ($userofexpensereport && is_object($userofexpensereport))
{
- $sql .= " , fk_user_author = ".($userofexpensereport->id > 0 ? "'".$userofexpensereport->id."'" : "null"); // Note fk_user_author is not the 'author' but the guy the expense report is for.
+ $sql .= " , fk_user_author = ".($userofexpensereport->id > 0 ? $userofexpensereport->id : "null"); // Note fk_user_author is not the 'author' but the guy the expense report is for.
}
$sql .= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator : "null");
$sql .= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid : "null");
@@ -845,24 +845,24 @@ class ExpenseReport extends CommonObject
$sql .= " WHERE de.fk_projet = ".$projectid;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
- $result = $db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
- $num = $db->num_rows($result);
+ $num = $this->db->num_rows($result);
$i = 0;
$total_HT = 0;
$total_TTC = 0;
while ($i < $num)
{
- $objp = $db->fetch_object($result);
+ $objp = $this->db->fetch_object($result);
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut";
$sql2 .= " FROM ".MAIN_DB_PREFIX."expensereport as d";
- $sql2 .= " WHERE d.rowid = '".$objp->fk_expensereport."'";
+ $sql2 .= " WHERE d.rowid = ".((int) $objp->fk_expensereport);
- $result2 = $db->query($sql2);
- $obj = $db->fetch_object($result2);
+ $result2 = $this->db->query($sql2);
+ $obj = $this->db->fetch_object($result2);
$objp->fk_user_author = $obj->fk_user_author;
$objp->ref = $obj->ref;
@@ -871,7 +871,7 @@ class ExpenseReport extends CommonObject
$total_HT = $total_HT + $objp->total_ht;
$total_TTC = $total_TTC + $objp->total_ttc;
- $author = new User($db);
+ $author = new User($this->db);
$author->fetch($objp->fk_user_author);
print '
';
@@ -920,7 +920,7 @@ class ExpenseReport extends CommonObject
print '| | ';
print '
';
} else {
- $this->error = $db->lasterror();
+ $this->error = $this->db->lasterror();
return -1;
}
}
@@ -1130,7 +1130,7 @@ class ExpenseReport extends CommonObject
// Validate
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
- $sql .= " SET ref = '".$num."',";
+ $sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " fk_statut = ".self::STATUS_VALIDATED.",";
$sql .= " date_valid='".$this->db->idate($this->date_valid)."',";
$sql .= " fk_user_valid = ".$user->id;
@@ -2354,7 +2354,7 @@ class ExpenseReport extends CommonObject
$type = 'expense_report';
- $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id;
+ $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
@@ -2740,7 +2740,7 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u
{
global $db, $langs;
- $tmpep = new ExpenseReport($db);
+ $tmpep = new ExpenseReport($this->db);
print '