mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-05 16:42:53 +01:00
Clean code
This commit is contained in:
@@ -132,7 +132,7 @@ abstract class CommonInvoice extends CommonObject
|
||||
|
||||
$sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$table;
|
||||
$sql .= ' WHERE '.$field.' = '.((int) $this->id);
|
||||
$sql .= " WHERE ".$field." = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -308,9 +308,8 @@ abstract class CommonInvoice extends CommonObject
|
||||
|
||||
$sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
|
||||
$sql .= ' WHERE pf.'.$field.' = '.((int) $this->id);
|
||||
//$sql.= ' WHERE pf.'.$field.' = 1';
|
||||
$sql .= ' AND pf.'.$field2.' = p.rowid';
|
||||
$sql .= " WHERE pf.".$field." = ".((int) $this->id);
|
||||
$sql .= " AND pf.".$field2." = p.rowid";
|
||||
$sql .= ' AND p.fk_paiement = t.id';
|
||||
$sql .= ' AND p.entity IN ('.getEntity($sharedentity).')';
|
||||
if ($filtertype) {
|
||||
|
||||
@@ -2054,7 +2054,7 @@ abstract class CommonObject
|
||||
}
|
||||
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
|
||||
$tmparray = explode('@', $this->ismultientitymanaged);
|
||||
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
|
||||
$sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity
|
||||
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
|
||||
}
|
||||
@@ -2075,13 +2075,13 @@ abstract class CommonObject
|
||||
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
||||
}
|
||||
if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
|
||||
$sql .= ' AND te.fk_soc = '.$socid;
|
||||
$sql .= ' AND te.fk_soc = '.((int) $socid);
|
||||
}
|
||||
if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
|
||||
$sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
|
||||
$sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)';
|
||||
}
|
||||
if ($restrictiononfksoc && $socid && $this->element == 'societe') {
|
||||
$sql .= ' AND te.rowid = '.$socid;
|
||||
$sql .= ' AND te.rowid = '.((int) $socid);
|
||||
}
|
||||
//print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
|
||||
|
||||
@@ -2124,7 +2124,7 @@ abstract class CommonObject
|
||||
}
|
||||
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
|
||||
$tmparray = explode('@', $this->ismultientitymanaged);
|
||||
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
|
||||
$sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity
|
||||
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
|
||||
}
|
||||
@@ -2145,13 +2145,13 @@ abstract class CommonObject
|
||||
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
||||
}
|
||||
if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
|
||||
$sql .= ' AND te.fk_soc = '.$socid;
|
||||
$sql .= ' AND te.fk_soc = '.((int) $socid);
|
||||
}
|
||||
if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
|
||||
$sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
|
||||
$sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)';
|
||||
}
|
||||
if ($restrictiononfksoc && $socid && $this->element == 'societe') {
|
||||
$sql .= ' AND te.rowid = '.$socid;
|
||||
$sql .= ' AND te.rowid = '.((int) $socid);
|
||||
}
|
||||
//print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
|
||||
// Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null
|
||||
@@ -2206,19 +2206,19 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
if (!empty($this->fields['fk_project'])) { // Common case
|
||||
if ($projectid) {
|
||||
$sql .= ' SET fk_project = '.((int) $projectid);
|
||||
$sql .= " SET fk_project = ".((int) $projectid);
|
||||
} else {
|
||||
$sql .= ' SET fk_project = NULL';
|
||||
$sql .= " SET fk_project = NULL";
|
||||
}
|
||||
$sql .= ' WHERE rowid = '.((int) $this->id);
|
||||
} elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm
|
||||
if ($projectid) {
|
||||
$sql .= ' SET fk_project = '.((int) $projectid);
|
||||
$sql .= " SET fk_project = ".((int) $projectid);
|
||||
} else {
|
||||
$sql .= ' SET fk_project = NULL';
|
||||
$sql .= " SET fk_project = NULL";
|
||||
}
|
||||
$sql .= ' WHERE id = '.((int) $this->id);
|
||||
} else // Special case for old architecture objects
|
||||
@@ -2266,8 +2266,8 @@ abstract class CommonObject
|
||||
$fieldname = 'fk_typepayment';
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2278,7 +2278,7 @@ abstract class CommonObject
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
dol_syslog(get_class($this).'::setPaymentMethods Error '.$sql.' - '.$this->db->error());
|
||||
dol_syslog(get_class($this).'::setPaymentMethods Error '.$this->db->error());
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
@@ -2302,7 +2302,7 @@ abstract class CommonObject
|
||||
$fieldname = 'multicurrency_code';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'";
|
||||
$sql .= " SET ".$fieldname." = '".$this->db->escape($code)."'";
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2340,7 +2340,7 @@ abstract class CommonObject
|
||||
$fieldname = 'multicurrency_tx';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.((float) $rate);
|
||||
$sql .= " SET ".$fieldname." = ".((float) $rate);
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2548,7 +2548,7 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
||||
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2590,7 +2590,7 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
||||
$sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2625,7 +2625,7 @@ abstract class CommonObject
|
||||
$fieldname = 'retained_warranty_fk_cond_reglement';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = '.((int) $id);
|
||||
$sql .= " SET ".$fieldname." = ".((int) $id);
|
||||
$sql .= ' WHERE rowid='.((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
@@ -2665,7 +2665,7 @@ abstract class CommonObject
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
dol_syslog(get_class($this).'::setDeliveryAddress Error '.$sql.' - '.$this->error);
|
||||
dol_syslog(get_class($this).'::setDeliveryAddress Error '.$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2884,7 +2884,7 @@ abstract class CommonObject
|
||||
// Count number of lines to reorder (according to choice $renum)
|
||||
$nl = 0;
|
||||
$sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.'='.((int) $this->id);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
if (!$renum) {
|
||||
$sql .= ' AND rang = 0';
|
||||
}
|
||||
@@ -2906,7 +2906,7 @@ abstract class CommonObject
|
||||
|
||||
// We first search all lines that are parent lines (for multilevel details lines)
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
if ($fk_parent_line) {
|
||||
$sql .= ' AND fk_parent_line IS NULL';
|
||||
}
|
||||
@@ -2954,7 +2954,7 @@ abstract class CommonObject
|
||||
$rows = array();
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND fk_parent_line = '.((int) $id);
|
||||
$sql .= ' ORDER BY rang ASC';
|
||||
|
||||
@@ -3031,7 +3031,7 @@ abstract class CommonObject
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
|
||||
dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG);
|
||||
@@ -3074,11 +3074,11 @@ abstract class CommonObject
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND rang = '.((int) ($rang - 1));
|
||||
if ($this->db->query($sql)) {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1));
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
if (!$this->db->query($sql)) {
|
||||
dol_print_error($this->db);
|
||||
@@ -3105,11 +3105,11 @@ abstract class CommonObject
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND rang = '.((int) ($rang + 1));
|
||||
if ($this->db->query($sql)) {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1));
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
if (!$this->db->query($sql)) {
|
||||
dol_print_error($this->db);
|
||||
@@ -3148,7 +3148,7 @@ abstract class CommonObject
|
||||
public function getIdOfLine($rang)
|
||||
{
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND rang = '.((int) $rang);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
@@ -3174,8 +3174,8 @@ abstract class CommonObject
|
||||
|
||||
// Search the last rang with fk_parent_line
|
||||
if ($fk_parent_line) {
|
||||
$sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND fk_parent_line = '.((int) $fk_parent_line);
|
||||
|
||||
dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
|
||||
@@ -3190,8 +3190,8 @@ abstract class CommonObject
|
||||
}
|
||||
} else {
|
||||
// If not, search the last rang of element
|
||||
$sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
$sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -3217,7 +3217,7 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||
$sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".((int) $this->id);
|
||||
|
||||
@@ -3268,7 +3268,7 @@ abstract class CommonObject
|
||||
} else {
|
||||
$fieldusermod = "fk_user_modif";
|
||||
}
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
|
||||
$sql .= ", ".$fieldusermod." = ".((int) $user->id);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
@@ -3386,21 +3386,21 @@ abstract class CommonObject
|
||||
$fieldup = 'value_unit';
|
||||
}
|
||||
|
||||
$sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,';
|
||||
$sql = "SELECT rowid, qty, ".$fieldup." as up, remise_percent, total_ht, ".$fieldtva." as total_tva, total_ttc, ".$fieldlocaltax1." as total_localtax1, ".$fieldlocaltax2." as total_localtax2,";
|
||||
$sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
|
||||
if ($this->table_element_line == 'facturedet') {
|
||||
$sql .= ', situation_percent';
|
||||
}
|
||||
$sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
if ($exclspec) {
|
||||
$product_field = 'product_type';
|
||||
if ($this->table_element_line == 'contratdet') {
|
||||
$product_field = ''; // contratdet table has no product_type field
|
||||
}
|
||||
if ($product_field) {
|
||||
$sql .= ' AND '.$product_field.' <> 9';
|
||||
$sql .= " AND ".$product_field." <> 9";
|
||||
}
|
||||
}
|
||||
$sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
|
||||
@@ -3553,14 +3553,14 @@ abstract class CommonObject
|
||||
|
||||
if (empty($nodatabaseupdate)) {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
|
||||
$sql .= " ".$fieldht." = ".price2num($this->total_ht).",";
|
||||
$sql .= " ".$fieldtva." = ".price2num($this->total_tva).",";
|
||||
$sql .= " ".$fieldlocaltax1." = ".price2num($this->total_localtax1).",";
|
||||
$sql .= " ".$fieldlocaltax2." = ".price2num($this->total_localtax2).",";
|
||||
$sql .= " ".$fieldttc." = ".price2num($this->total_ttc);
|
||||
$sql .= ", multicurrency_total_ht = ".price2num($this->multicurrency_total_ht, 'MT', 1);
|
||||
$sql .= ", multicurrency_total_tva = ".price2num($this->multicurrency_total_tva, 'MT', 1);
|
||||
$sql .= ", multicurrency_total_ttc = ".price2num($this->multicurrency_total_ttc, 'MT', 1);
|
||||
$sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).",";
|
||||
$sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).",";
|
||||
$sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).",";
|
||||
$sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).",";
|
||||
$sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc));
|
||||
$sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1));
|
||||
$sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1));
|
||||
$sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1));
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
|
||||
@@ -4038,7 +4038,7 @@ abstract class CommonObject
|
||||
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT '.$field_select.' FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where);
|
||||
$sql = "SELECT ".$field_select." FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
$TRes = array();
|
||||
@@ -4067,7 +4067,7 @@ abstract class CommonObject
|
||||
|
||||
global $db;
|
||||
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if (empty($resql)) {
|
||||
@@ -5317,7 +5317,7 @@ abstract class CommonObject
|
||||
$update_main_doc_field = 1;
|
||||
}
|
||||
if ($update_main_doc_field && !empty($this->table_element)) {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath."/".$ecmfile->filename)."'";
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -6677,17 +6677,17 @@ abstract class CommonObject
|
||||
|
||||
//We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
||||
$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
||||
$sql .= " as main, ".MAIN_DB_PREFIX.$InfoFieldList[0]."_extrafields as extra";
|
||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
||||
}
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE 1=1';
|
||||
}
|
||||
// Some tables may have field, some other not. For the moment we disable it.
|
||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||
$sqlwhere .= ' AND entity = '.$conf->entity;
|
||||
$sqlwhere .= " AND entity = ".((int) $conf->entity);
|
||||
}
|
||||
$sql .= $sqlwhere;
|
||||
//print $sql;
|
||||
@@ -6830,16 +6830,16 @@ abstract class CommonObject
|
||||
// We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
||||
$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
||||
}
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE 1=1';
|
||||
}
|
||||
// Some tables may have field, some other not. For the moment we disable it.
|
||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||
$sqlwhere .= ' AND entity = '.$conf->entity;
|
||||
$sqlwhere .= " AND entity = ".((int) $conf->entity);
|
||||
}
|
||||
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
|
||||
// print $sql;
|
||||
@@ -8770,8 +8770,8 @@ abstract class CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sql = 'SELECT '.$fieldlist;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
$sql = "SELECT ".$fieldlist;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
|
||||
if (!empty($id)) {
|
||||
$sql .= ' WHERE t.rowid = '.((int) $id);
|
||||
@@ -8825,9 +8825,9 @@ abstract class CommonObject
|
||||
|
||||
$objectline = new $objectlineclassname($this->db);
|
||||
|
||||
$sql = 'SELECT '.$objectline->getFieldList('l');
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element.' as l';
|
||||
$sql .= ' WHERE l.fk_'.$this->element.' = '.((int) $this->id);
|
||||
$sql = "SELECT ".$objectline->getFieldList('l');
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l";
|
||||
$sql .= " WHERE l.fk_".$this->element." = ".((int) $this->id);
|
||||
if ($morewhere) {
|
||||
$sql .= $morewhere;
|
||||
}
|
||||
@@ -8973,7 +8973,7 @@ abstract class CommonObject
|
||||
|
||||
if ($forcechilddeletion) { // Force also delete of childtables that should lock deletion in standard case when option force is off
|
||||
foreach ($this->childtables as $table) {
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->error = $this->db->lasterror();
|
||||
@@ -9022,7 +9022,7 @@ abstract class CommonObject
|
||||
}
|
||||
} else {
|
||||
// Delete record in child table
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
@@ -9100,7 +9100,7 @@ abstract class CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' WHERE '.$parentField.' = '.(int) $parentId;
|
||||
$sql .= " WHERE ".$parentField." = ".(int) $parentId;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
@@ -9533,7 +9533,7 @@ abstract class CommonObject
|
||||
// Delete in database with mode 1
|
||||
if ($mode == 1) {
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
|
||||
$sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id).")";
|
||||
$sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id).")";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->error = $this->db->lasterror();
|
||||
@@ -9542,7 +9542,7 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files";
|
||||
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id);
|
||||
$sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->error = $this->db->lasterror();
|
||||
|
||||
@@ -86,7 +86,7 @@ abstract class CommonObjectLine extends CommonObject
|
||||
$label_type = 'code';
|
||||
}
|
||||
|
||||
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
|
||||
$sql = "SELECT ".$label_type.", code from ".MAIN_DB_PREFIX."c_units where rowid = ".((int) $this->fk_unit);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
$res = $this->db->fetch_array($resql);
|
||||
@@ -98,7 +98,7 @@ abstract class CommonObjectLine extends CommonObject
|
||||
$this->db->free($resql);
|
||||
return $label;
|
||||
} else {
|
||||
$this->error = $this->db->error().' sql='.$sql;
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class CoreObject extends CommonObject
|
||||
|
||||
$this->{$className} = array();
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$res = $this->db->query($sql);
|
||||
|
||||
if ($res) {
|
||||
|
||||
@@ -516,10 +516,10 @@ class DiscountAbsolute
|
||||
$sql .= " AND rc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($filter) {
|
||||
$sql .= ' AND ('.$filter.')';
|
||||
$sql .= " AND (".$filter.")";
|
||||
}
|
||||
if ($maxvalue) {
|
||||
$sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue);
|
||||
$sql .= ' AND rc.amount_ttc <= '.((float) price2num($maxvalue));
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -555,12 +555,12 @@ class DiscountAbsolute
|
||||
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
|
||||
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $invoice->id);
|
||||
$sql .= ' AND f.type = 3';
|
||||
} elseif ($invoice->element == 'invoice_supplier') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $invoice->id);
|
||||
$sql .= ' AND f.type = 3';
|
||||
} else {
|
||||
$this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter";
|
||||
@@ -596,13 +596,13 @@ class DiscountAbsolute
|
||||
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
|
||||
$sql .= ' AND f.type IN ('.$this->db->sanitize($invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION).')'; // Find discount coming from credit note or excess received
|
||||
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $invoice->id);
|
||||
$sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE.", ".$invoice::TYPE_SITUATION).')'; // Find discount coming from credit note or excess received
|
||||
} elseif ($invoice->element == 'invoice_supplier') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
|
||||
$sql .= ' AND f.type IN ('.$this->db->sanitize($invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE).')'; // Find discount coming from credit note or excess paid
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $invoice->id);
|
||||
$sql .= " AND f.type IN (".$this->db->sanitize($invoice::TYPE_STANDARD.", ".$invoice::TYPE_CREDIT_NOTE).')'; // Find discount coming from credit note or excess paid
|
||||
} else {
|
||||
$this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
|
||||
dol_print_error($this->error);
|
||||
@@ -636,11 +636,11 @@ class DiscountAbsolute
|
||||
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
|
||||
$sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id;
|
||||
$sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.((int) $invoice->id);
|
||||
} elseif ($invoice->element == 'invoice_supplier') {
|
||||
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id;
|
||||
$sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.((int) $invoice->id);
|
||||
} else {
|
||||
$this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
|
||||
dol_print_error($this->error);
|
||||
|
||||
@@ -867,7 +867,7 @@ class dolReceiptPrinter extends Printer
|
||||
$error = 0;
|
||||
$sql = 'SELECT template';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
|
||||
$sql .= ' WHERE rowid='.$templateid;
|
||||
$sql .= ' WHERE rowid = '.((int) $templateid);
|
||||
$sql .= ' AND entity = '.$conf->entity;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
@@ -905,7 +905,7 @@ class dolReceiptPrinter extends Printer
|
||||
$sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
|
||||
$sql .= ' WHERE rowid = '.((int) $printerid);
|
||||
$sql .= ' AND entity = '.$conf->entity;
|
||||
$sql .= ' AND entity = '.((int) $conf->entity);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_array($resql);
|
||||
|
||||
@@ -1273,16 +1273,16 @@ class ExtraFields
|
||||
//We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
||||
$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
||||
}
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE 1=1';
|
||||
}
|
||||
// Some tables may have field, some other not. For the moment we disable it.
|
||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||
$sqlwhere .= ' AND entity = '.$conf->entity;
|
||||
$sqlwhere .= ' AND entity = '.((int) $conf->entity);
|
||||
}
|
||||
$sql .= $sqlwhere;
|
||||
//print $sql;
|
||||
@@ -1485,16 +1485,16 @@ class ExtraFields
|
||||
// We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra.') !== false) {
|
||||
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
||||
$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
||||
}
|
||||
} else {
|
||||
$sqlwhere .= ' WHERE 1=1';
|
||||
}
|
||||
// Some tables may have field, some other not. For the moment we disable it.
|
||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||
$sqlwhere .= ' AND entity = '.$conf->entity;
|
||||
$sqlwhere .= " AND entity = ".((int) $conf->entity);
|
||||
}
|
||||
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
|
||||
// print $sql;
|
||||
|
||||
@@ -172,6 +172,7 @@ class HookManager
|
||||
'addSearchEntry',
|
||||
'addStatisticLine',
|
||||
'addSectionECMAuto',
|
||||
'checkSecureAccess',
|
||||
'createDictionaryFieldlist',
|
||||
'editDictionaryFieldlist',
|
||||
'getFormMail',
|
||||
|
||||
@@ -2565,7 +2565,7 @@ class Form
|
||||
$sql .= ')';
|
||||
}
|
||||
if (count($warehouseStatusArray)) {
|
||||
$sql .= ' GROUP BY'.$selectFields;
|
||||
$sql .= " GROUP BY ".$selectFields;
|
||||
}
|
||||
|
||||
//Sort by category
|
||||
@@ -6988,7 +6988,7 @@ class Form
|
||||
if (isset($objecttmp->ismultientitymanaged)) {
|
||||
if (!is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$tmparray = explode('@', $objecttmp->ismultientitymanaged);
|
||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON parenttable.rowid = t.".$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
@@ -7009,7 +7009,7 @@ class Form
|
||||
$sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
||||
}
|
||||
if (!is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$sql .= ' AND parenttable.entity = t.'.$tmparray[0];
|
||||
$sql .= " AND parenttable.entity = t.".$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
|
||||
if ($objecttmp->element == 'societe') {
|
||||
|
||||
@@ -601,7 +601,7 @@ class FormMail extends Form
|
||||
|
||||
// Add also email aliases from the c_email_senderprofile table
|
||||
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
|
||||
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
|
||||
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.((int) $user->id).')';
|
||||
$sql .= ' ORDER BY position';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
@@ -1088,11 +1088,11 @@ class Utils
|
||||
fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM '.$table; // Here SELECT * is allowed because we don't have definition of columns to take
|
||||
$sql = "SELECT * FROM ".$table; // Here SELECT * is allowed because we don't have definition of columns to take
|
||||
$result = $db->query($sql);
|
||||
while ($row = $db->fetch_row($result)) {
|
||||
// For each row of data we print a line of INSERT
|
||||
fwrite($handle, 'INSERT '.$delayed.$ignore.'INTO `'.$table.'` VALUES (');
|
||||
fwrite($handle, "INSERT ".$delayed.$ignore."INTO ".$table." VALUES (");
|
||||
$columns = count($row);
|
||||
for ($j = 0; $j < $columns; $j++) {
|
||||
// Processing each columns of the row to ensure that we correctly save the value (eg: add quotes for string - in fact we add quotes for everything, it's easier)
|
||||
|
||||
@@ -263,7 +263,7 @@ class Validate
|
||||
}
|
||||
|
||||
foreach ($value_arr as $val) {
|
||||
$sql = 'SELECT ' . $col . ' FROM ' . MAIN_DB_PREFIX . $table . " WHERE " . $col ." = '" . $this->db->escape($val) . "'"; // nore quick than count(*) to check existing of a row
|
||||
$sql = "SELECT ".$col." FROM ".MAIN_DB_PREFIX.$table." WHERE ".$col." = '".$this->db->escape($val)."'"; // nore quick than count(*) to check existing of a row
|
||||
$resql = $this->db->getRow($sql);
|
||||
if ($resql) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user