[-] WS : Fixed norm on WebserviceRequest
This commit is contained in:
@@ -1122,9 +1122,7 @@ class WebserviceRequestCore
|
||||
$sql_sort .= 'main_i18n.`'.pSQL($this->resourceConfiguration['fields'][$fieldName]['sqlId']).'` '.$direction.', ';// ORDER BY main_i18n.`field` ASC|DESC
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_sort .= (isset($this->resourceConfiguration['retrieveData']['tableAlias']) ? $this->resourceConfiguration['retrieveData']['tableAlias'].'.' : '').'`'.pSQL($this->resourceConfiguration['fields'][$fieldName]['sqlId']).'` '.$direction.', ';// ORDER BY `field` ASC|DESC
|
||||
}
|
||||
}
|
||||
$sql_sort = rtrim($sql_sort, ', ')."\n";
|
||||
}
|
||||
@@ -1169,9 +1167,7 @@ class WebserviceRequestCore
|
||||
if ($sqlObjects)
|
||||
{
|
||||
foreach ($sqlObjects as $sqlObject)
|
||||
{
|
||||
$objects[] = new $this->resourceConfiguration['retrieveData']['className']($sqlObject[$this->resourceConfiguration['fields']['id']['sqlId']]);
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
}
|
||||
@@ -1254,12 +1250,8 @@ class WebserviceRequestCore
|
||||
protected function executeEntityPut()
|
||||
{
|
||||
return $this->saveEntityFromXml(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Execute DELETE method on a PrestaShop entity
|
||||
*
|
||||
@@ -1328,12 +1320,6 @@ class WebserviceRequestCore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write XML output after GET and HEAD action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/**
|
||||
* save Entity Object from XML
|
||||
*
|
||||
@@ -1525,42 +1511,40 @@ class WebserviceRequestCore
|
||||
protected function getSQLRetrieveFilter($sqlId, $filterValue, $tableAlias = 'main.')
|
||||
{
|
||||
$ret = '';
|
||||
// "LIKE" case (=%[foo]%, =%[foo], =[foo]%)
|
||||
preg_match('/^(.*)\[(.*)\](.*)$/', $filterValue, $matches);
|
||||
if (count($matches) > 1)
|
||||
{
|
||||
if ($matches[1] == '%' || $matches[3] == '%')
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` LIKE "'.$matches[1].pSQL($matches[2]).$matches[3]."\"\n";// AND field LIKE %value%
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` LIKE "'.$matches[1].pSQL($matches[2]).$matches[3]."\"\n";
|
||||
elseif ($matches[1] == '' && $matches[3] == '')
|
||||
{
|
||||
// "OR" case
|
||||
if (strpos($matches[2], '|') > 0)
|
||||
{
|
||||
$values = explode('|', $matches[2]);
|
||||
$ret .= ' AND (';
|
||||
$temp = '';
|
||||
foreach ($values as $value)
|
||||
$temp .= $tableAlias.'`'.pSQL($sqlId).'` = "'.pSQL($value).'" OR ';// AND (field = value3 OR field = value7 OR field = value9)
|
||||
$temp .= $tableAlias.'`'.pSQL($sqlId).'` = "'.pSQL($value).'" OR ';
|
||||
$ret .= rtrim($temp, 'OR ').')'."\n";
|
||||
}
|
||||
elseif (preg_match('/^([\d\.:-\s]+),([\d\.:-\s]+)$/', $matches[2], $matches3))// "AND" case
|
||||
elseif (preg_match('/^([\d\.:-\s]+),([\d\.:-\s]+)$/', $matches[2], $matches3))
|
||||
{
|
||||
unset($matches3[0]);
|
||||
if (count($matches3) > 0)
|
||||
{
|
||||
sort($matches3);
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` BETWEEN "'.$matches3[0].'" AND "'.$matches3[1]."\"\n";// AND field BETWEEN value3 AND value4
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` BETWEEN "'.pSQL($matches3[0]).'" AND "'.pSQL($matches3[1])."\"\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'`="'.$matches[2].'"'."\n";// AND field = value1
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'`="'.pSQL($matches[2]).'"'."\n";
|
||||
}
|
||||
elseif ($matches[1] == '>')
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` > "'.pSQL($matches[2])."\"\n";// AND field > value3
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` > "'.pSQL($matches[2])."\"\n";
|
||||
elseif ($matches[1] == '<')
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` < "'.pSQL($matches[2])."\"\n";// AND field < value3
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` < "'.pSQL($matches[2])."\"\n";
|
||||
elseif ($matches[1] == '!')
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` != "'.pSQL($matches[2])."\"\n";// AND field IS NOT value3
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` != "'.pSQL($matches[2])."\"\n";
|
||||
}
|
||||
else
|
||||
$ret .= ' AND '.$tableAlias.'`'.pSQL($sqlId).'` '.(Validate::isFloat(pSQL($filterValue)) ? 'LIKE' : '=').' "'.pSQL($filterValue)."\"\n";
|
||||
|
||||
Reference in New Issue
Block a user