diff --git a/src/vitis/vas/rest/ws/vitis/GenericQuerys.class.inc b/src/vitis/vas/rest/ws/vitis/GenericQuerys.class.inc index ae3ade89fea7b65a19aed0869f12b0357b914be6..7394491a162f775ffb0d7ec7731e124bbb5621c9 100644 --- a/src/vitis/vas/rest/ws/vitis/GenericQuerys.class.inc +++ b/src/vitis/vas/rest/ws/vitis/GenericQuerys.class.inc @@ -457,7 +457,6 @@ class GenericQuerys extends Vitis { $this->aValues['password'] = ''; } } - $this->oBd = new BD($this->aValues['login'], $this->aValues['password'], $this->aValues['database'], $this->aValues['server'], $this->aValues['port'], $this->aValues['sgbd'], $this->aValues['encoding']); if ($this->oBd->erreurRencontree) { writeToErrorLog(ERROR_CONNECTION_PROBLEM); @@ -525,6 +524,28 @@ class GenericQuerys extends Vitis { $this->oBd = new BD($this->aValues['login'], $this->aValues['password'], $sDatabase, $this->aValues['server'], $this->aValues['port'], $this->aValues['sgbd'], $this->aValues['encoding']); $sSql = $this->aSql[$this->aValues['sgbd']]['getSchemas']; $aSQLParams = array(); + //order by + if (!empty($this->aValues['order_by'])) { + $aOrder = explode("|", $this->aValues['order_by']); + foreach ($aOrder as $value) { + $sColumnKey = 'column_' . vitisUniqId(); + if (strpos($sSql, "ORDER BY") == FALSE) + $sSql .= " ORDER BY " . str_replace("=", " ", "[" . $sColumnKey . "]"); + else + $sSql .= ", " . str_replace("=", " ", "[" . $sColumnKey . "]"); + $aSQLParams[$sColumnKey] = array('value' => $value, 'type' => 'column_name'); + } + } + // sort_order + if (!empty($this->aValues['sort_order'])) { + switch (strtoupper($this->aValues['sort_order'])) { + case 'DESC': + $sSql .= " DESC"; + break; + default: + $sSql .= " ASC"; + } + } $oPDOresult = $this->oBd->executeWithParams($sSql, $aSQLParams); if ($this->oBd->enErreur()) { $oError = new VitisError(1, $this->oBd->getBDMessage());