FIX : better fetchAll method into skeleton_class.class.php
This commit is contained in:
parent
5cea60cf58
commit
73192b78e9
@ -222,10 +222,11 @@ class Skeleton_Class extends CommonObject
|
||||
* @param int $limit offset limit
|
||||
* @param int $offset offset limit
|
||||
* @param array $filter filter array
|
||||
* @param string $filtermode filter mode (AND or OR)
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetchAll($sortorder, $sortfield, $limit, $offset, array $filter = array())
|
||||
public function fetchAll($sortorder, $sortfield, $limit, $offset, array $filter = array(), $filtermode='AND')
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@ -240,14 +241,19 @@ class Skeleton_Class extends CommonObject
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
$sqlwhere [] = ' AND ' . $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' WHERE ' . implode(' AND ', $sqlwhere);
|
||||
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||
}
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder;
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ' . $this->db->plimit($limit + 1, $offset);
|
||||
|
||||
$this->lines = array();
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user