Преглед изворни кода

added support for wfs arg primaryKey as array - csv

Piotr Labudda пре 8 година
родитељ
комит
dc789ad665
2 измењених фајлова са 11 додато и 4 уклоњено
  1. 10 3
      SE/se-lib/AclQueryFeatures.php
  2. 1 1
      SE/se-lib/Api/Wfs/GetFeature.php

+ 10 - 3
SE/se-lib/AclQueryFeatures.php

@@ -298,9 +298,16 @@ class AclQueryFeatures {
 			} else if ('primaryKey' === $k) {
 				$fieldName = $this->_acl->getPrimaryKeyField();
 				$fieldType = $this->_acl->getXsdFieldType($fieldName);
-				list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
-				DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
-				$this->_query->where([$fieldName, $comparisonSign, $value]);
+				if (is_array($v)) {
+					DBG::log([ $fieldName, $v, $fieldType ], 'array', "parseQueryValue :: primaryKey, value is array");
+					$this->_query->where([ $fieldName, 'or', array_map(function ($pk) use ($fieldName) {
+						return [ $fieldName, '=', $pk ];
+					}, $v) ]);
+				} else {
+					list($comparisonSign, $value) = $this->parseQueryValue($fieldName, $v, $fieldType);
+					DBG::log([ $fieldName, $comparisonSign, $value, $fieldType ], 'array', "parseQueryValue");
+					$this->_query->where([$fieldName, $comparisonSign, $value]);
+				}
 			} else if ('__backRef' === $k) { // skip - parse below
 			} else if ('__childRef' === $k) { // skip - parse below
 			} else if ('limit' === $k) {

+ 1 - 1
SE/se-lib/Api/Wfs/GetFeature.php

@@ -112,7 +112,7 @@ class Api_Wfs_GetFeature {
 
 		$pk = V::get('primarykey', '', $lowerArgs);
 		if ($pk) {
-			$args['primaryKey'] = $pk;
+			$args['primaryKey'] = (false !== strpos($pk, ',')) ? explode(',', $pk) : $pk;
 		}
 
 		if(DBG::isActive() && V::get('DBG', 0, $_GET)){ echo "\$lowerArgs:";print_r($lowerArgs); }