Skip to content
Snippets Groups Projects
Commit 9c4d60fd authored by Juanjo Menent's avatar Juanjo Menent Committed by GitHub
Browse files

Merge pull request #5639 from atm-florian/4.0

fix ressource module  for PGSQL and coding style
parents ed25c0fd 848d046b
No related branches found
No related tags found
No related merge requests found
......@@ -339,7 +339,7 @@ class Dolresource extends CommonObject
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id = ".$this->db->escape($rowid);
$sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($this->db->query($sql))
{
......@@ -393,7 +393,6 @@ class Dolresource extends CommonObject
}
}
}
//$sql.= " GROUP BY t.rowid, t.entity, t.ref, t.description, t.fk_code_type_resource, t.tms, ty.label";
$sql.= $this->db->order($sortfield,$sortorder);
$this->num_all = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
......@@ -410,10 +409,9 @@ class Dolresource extends CommonObject
$num = $this->db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
$this->lines=array();
while ($obj = $this->db->fetch_object($resql))
{
$obj = $this->db->fetch_object($resql);
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->ref = $obj->ref;
......@@ -421,8 +419,7 @@ class Dolresource extends CommonObject
$line->fk_code_type_resource = $obj->fk_code_type_resource;
$line->type_label = $obj->type_label;
$this->lines[$i] = $line;
$i++;
$this->lines[] = $line;
}
$this->db->free($resql);
}
......@@ -473,7 +470,6 @@ class Dolresource extends CommonObject
}
}
}
//$sql.= " GROUP BY t.rowid, ty.label";
$sql.= $this->db->order($sortfield,$sortorder);
if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
......@@ -484,10 +480,8 @@ class Dolresource extends CommonObject
$num = $this->db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
while ($obj = $this->db->fetch_object($resql))
{
$obj = $this->db->fetch_object($resql);
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->resource_id = $obj->resource_id;
......@@ -502,9 +496,8 @@ class Dolresource extends CommonObject
$line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type);
if($obj->element_id && $obj->element_type)
$line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type);
$this->lines[$i] = $line;
$this->lines[] = $line;
$i++;
}
$this->db->free($resql);
}
......@@ -559,7 +552,6 @@ class Dolresource extends CommonObject
}
}
}
//$sql.= " GROUP BY t.resource_id";
$sql.= $this->db->order($sortfield,$sortorder);
if ($limit) $sql.= $this->db->plimit($limit+1,$offset);
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG);
......@@ -570,10 +562,9 @@ class Dolresource extends CommonObject
$num = $this->db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
$this->lines=array();
while ($obj = $this->db->fetch_object($resql))
{
$obj = $this->db->fetch_object($resql);
$line = new Dolresource($this->db);
$line->id = $obj->rowid;
$line->resource_id = $obj->resource_id;
......@@ -584,9 +575,7 @@ class Dolresource extends CommonObject
$line->mandatory = $obj->mandatory;
$line->fk_user_create = $obj->fk_user_create;
$this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type);
$i++;
$this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type);
}
$this->db->free($resql);
}
......@@ -759,7 +748,7 @@ class Dolresource extends CommonObject
/**
* Return an array with resources linked to the element
*
*
* @param string $element Element
* @param int $element_id Id
* @param string $resource_type Type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment