Просмотр исходного кода

fixed ACL::fetchRefs total query

Piotr Labudda 8 лет назад
Родитель
Сommit
d70c462801

+ 6 - 1
SE/se-lib/ACL.php

@@ -450,7 +450,12 @@ class ACL {
 		$refConf = ACL::getRefConfig($namespace, $childTypeName);
 		$refTable = $refConf->tableName; // ACL::getRefTable($namespace, $childTypeName);
 		if (V::get('total', false, $params)) {
-			return DB::getPDO()->fetchValue(" select count(*) as cnt from `{$refTable}` where PRIMARY_KEY = :primary_key and A_STATUS not in ('DELETED') ", [ ':primary_key' => $primaryKey ]);
+			return (int)DB::getPDO()->fetchValue("
+				select count( DISTINCT REMOTE_PRIMARY_KEY ) as cnt
+				from `{$refTable}`
+				where PRIMARY_KEY = :primary_key
+					and A_STATUS not in ('DELETED')
+			", [ ':primary_key' => $primaryKey ]);
 		}
 
 		return DB::getPDO()->fetchValuesList("

+ 1 - 1
SE/se-lib/Api/Process/P5/CreateRelations.php

@@ -33,7 +33,7 @@ class Api_Process_P5_CreateRelations { // TODO: extends Api_ProcessBase
 			'msg' => "done",
 			// 'body' => [
 			// 	'relations' => $listRelations,
-			// 	'total' => $total,
+			// 	'total' => $totalRelations,
 			// ]
 		]);
 		exit;

+ 1 - 1
SE/se-lib/Api/Process/P5/DeleteRelations.php

@@ -33,7 +33,7 @@ class Api_Process_P5_DeleteRelations { // TODO: extends Api_ProcessBase
 			'msg' => "done",
 			// 'body' => [
 			// 	'relations' => $listRelations,
-			// 	'total' => $total,
+			// 	'total' => $totalRelations,
 			// ]
 		]);
 		exit;

+ 1 - 1
SE/se-lib/Api/Process/P5/GetRelations.php

@@ -40,7 +40,7 @@ class Api_Process_P5_GetRelations { // TODO: extends Api_ProcessBase
 				],
 				'total' => $totalRelations,
 				'relations' => $listRelations,
-				// 'total' => $total,
+				// 'DBG__total' => ACL::fetchRefs(Api_WfsNs::toNamespace($typeName), $primaryKey, $remoteTypeName, [ 'total' => true ]),
 			]
 		]);
 		exit;