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
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
$sql = "INSERT INTO ".$this->db->prefix().$this->table_element." (";
$sql .= "title, expression";
$sql .= ") VALUES (";
$sql .= " ".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "''").",";
@ -104,7 +104,7 @@ class PriceExpression
}
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)
//{
@ -148,7 +148,7 @@ class PriceExpression
}
$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);
dol_syslog(__METHOD__);
@ -179,7 +179,7 @@ class PriceExpression
{
// phpcs:enable
$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";
dol_syslog(__METHOD__, LOG_DEBUG);
@ -215,7 +215,7 @@ class PriceExpression
{
// phpcs:enable
$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)."'";
dol_syslog(__METHOD__, LOG_DEBUG);
@ -254,7 +254,7 @@ class PriceExpression
}
// 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 .= " expression = ".(isset($this->expression) ? "'".$this->db->escape($this->expression)."'" : "''")."";
$sql .= " WHERE rowid = ".((int) $this->id);
@ -326,7 +326,7 @@ class PriceExpression
//}
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);
dol_syslog(__METHOD__);

View File

@ -88,7 +88,7 @@ class PriceGlobalVariable
$this->checkParameters();
// 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 .= ") VALUES (";
$sql .= " ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "''").",";
@ -105,7 +105,7 @@ class PriceGlobalVariable
}
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) {
// Uncomment this and change MYOBJECT to your own tag if you
@ -142,7 +142,7 @@ class PriceGlobalVariable
public function fetch($id)
{
$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);
dol_syslog(__METHOD__);
@ -179,7 +179,7 @@ class PriceGlobalVariable
$this->checkParameters();
// 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 .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
$sql .= " value = ".((float) $this->value);
@ -249,7 +249,7 @@ class PriceGlobalVariable
}
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);
dol_syslog(__METHOD__);
@ -316,7 +316,7 @@ class PriceGlobalVariable
public function listGlobalVariables()
{
$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";
dol_syslog(__METHOD__, LOG_DEBUG);

View File

@ -100,7 +100,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters();
// 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 .= ") VALUES (";
$sql .= " ".((int) $this->type).",";
@ -121,7 +121,7 @@ class PriceGlobalVariableUpdater
}
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) {
// Uncomment this and change MYOBJECT to your own tag if you
@ -158,7 +158,7 @@ class PriceGlobalVariableUpdater
public function fetch($id)
{
$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);
dol_syslog(__METHOD__);
@ -199,7 +199,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters();
// 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 .= " description = ".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "''").",";
$sql .= " parameters = ".(isset($this->parameters) ? "'".$this->db->escape($this->parameters)."'" : "''").",";
@ -274,7 +274,7 @@ class PriceGlobalVariableUpdater
//}
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);
dol_syslog(__METHOD__);
@ -372,7 +372,7 @@ class PriceGlobalVariableUpdater
public function listUpdaters()
{
$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);
$resql = $this->db->query($sql);
@ -409,7 +409,7 @@ class PriceGlobalVariableUpdater
public function listPendingUpdaters()
{
$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();
dol_syslog(__METHOD__, LOG_DEBUG);
@ -568,7 +568,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters();
// 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 .= " WHERE rowid = ".((int) $this->id);
@ -612,7 +612,7 @@ class PriceGlobalVariableUpdater
$this->checkParameters();
// 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 .= " WHERE rowid = ".((int) $this->id);