FIX convert dynamic_price class

This commit is contained in:
Regis Houssin 2022-01-27 10:15:08 +01:00
parent 116bcd1bdc
commit 9278c7cb85
3 changed files with 22 additions and 22 deletions

View File

@ -88,7 +88,7 @@ class PriceExpression
} }
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "title, expression"; $sql .= "title, expression";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " ".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "''").","; $sql .= " ".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "''").",";
@ -104,7 +104,7 @@ class PriceExpression
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
//if (! $notrigger) //if (! $notrigger)
//{ //{
@ -148,7 +148,7 @@ class PriceExpression
} }
$sql = "SELECT title, expression"; $sql = "SELECT title, expression";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);
@ -179,7 +179,7 @@ class PriceExpression
{ {
// phpcs:enable // phpcs:enable
$sql = "SELECT rowid, title, expression"; $sql = "SELECT rowid, title, expression";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " ORDER BY title"; $sql .= " ORDER BY title";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -215,7 +215,7 @@ class PriceExpression
{ {
// phpcs:enable // phpcs:enable
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE title = '".$this->db->escape($title)."'"; $sql .= " WHERE title = '".$this->db->escape($title)."'";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -254,7 +254,7 @@ class PriceExpression
} }
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " title = ".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "''").","; $sql .= " title = ".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "''").",";
$sql .= " expression = ".(isset($this->expression) ? "'".$this->db->escape($this->expression)."'" : "''").""; $sql .= " expression = ".(isset($this->expression) ? "'".$this->db->escape($this->expression)."'" : "''")."";
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
@ -326,7 +326,7 @@ class PriceExpression
//} //}
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $rowid); $sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);

View File

@ -88,7 +88,7 @@ class PriceGlobalVariable
$this->checkParameters(); $this->checkParameters();
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "code, description, value"; $sql .= "code, description, value";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "''").","; $sql .= " ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "''").",";
@ -105,7 +105,7 @@ class PriceGlobalVariable
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
if (!$notrigger) { if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
@ -142,7 +142,7 @@ class PriceGlobalVariable
public function fetch($id) public function fetch($id)
{ {
$sql = "SELECT code, description, value"; $sql = "SELECT code, description, value";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);
@ -179,7 +179,7 @@ class PriceGlobalVariable
$this->checkParameters(); $this->checkParameters();
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " code = ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "''").","; $sql .= " code = ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "''").",";
$sql .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").","; $sql .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
$sql .= " value = ".((float) $this->value); $sql .= " value = ".((float) $this->value);
@ -249,7 +249,7 @@ class PriceGlobalVariable
} }
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $rowid); $sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);
@ -316,7 +316,7 @@ class PriceGlobalVariable
public function listGlobalVariables() public function listGlobalVariables()
{ {
$sql = "SELECT rowid, code, description, value"; $sql = "SELECT rowid, code, description, value";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " ORDER BY code"; $sql .= " ORDER BY code";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);

View File

@ -100,7 +100,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters(); $this->checkParameters();
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "type, description, parameters, fk_variable, update_interval, next_update, last_status"; $sql .= "type, description, parameters, fk_variable, update_interval, next_update, last_status";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " ".((int) $this->type).","; $sql .= " ".((int) $this->type).",";
@ -121,7 +121,7 @@ class PriceGlobalVariableUpdater
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
if (!$notrigger) { if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you // Uncomment this and change MYOBJECT to your own tag if you
@ -158,7 +158,7 @@ class PriceGlobalVariableUpdater
public function fetch($id) public function fetch($id)
{ {
$sql = "SELECT type, description, parameters, fk_variable, update_interval, next_update, last_status"; $sql = "SELECT type, description, parameters, fk_variable, update_interval, next_update, last_status";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);
@ -199,7 +199,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters(); $this->checkParameters();
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " type = ".((int) $this->type).","; $sql .= " type = ".((int) $this->type).",";
$sql .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").","; $sql .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
$sql .= " parameters = ".(isset($this->parameters) ? "'".$this->db->escape($this->parameters)."'" : "''").","; $sql .= " parameters = ".(isset($this->parameters) ? "'".$this->db->escape($this->parameters)."'" : "''").",";
@ -274,7 +274,7 @@ class PriceGlobalVariableUpdater
//} //}
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql = "DELETE FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE rowid = ".((int) $rowid); $sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(__METHOD__); dol_syslog(__METHOD__);
@ -372,7 +372,7 @@ class PriceGlobalVariableUpdater
public function listUpdaters() public function listUpdaters()
{ {
$sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status"; $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -409,7 +409,7 @@ class PriceGlobalVariableUpdater
public function listPendingUpdaters() public function listPendingUpdaters()
{ {
$sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status"; $sql = "SELECT rowid, type, description, parameters, fk_variable, update_interval, next_update, last_status";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".$this->db->prefix().$this->table_element;
$sql .= " WHERE next_update < ".dol_now(); $sql .= " WHERE next_update < ".dol_now();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -568,7 +568,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters(); $this->checkParameters();
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " next_update = ".$this->next_update; $sql .= " next_update = ".$this->next_update;
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
@ -612,7 +612,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters(); $this->checkParameters();
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".$this->db->prefix().$this->table_element." SET";
$sql .= " last_status = ".(isset($this->last_status) ? "'".$this->db->escape($this->last_status)."'" : "''"); $sql .= " last_status = ".(isset($this->last_status) ? "'".$this->db->escape($this->last_status)."'" : "''");
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);