Explorar el Código

fixed getItems in SystemObject

Piotr Labudda hace 9 años
padre
commit
2d734ddc50
Se han modificado 2 ficheros con 30 adiciones y 2 borrados
  1. 23 0
      SE/se-lib/AclQueryItems.php
  2. 7 2
      SE/se-lib/Schema/SystemObjectStorageAcl.php

+ 23 - 0
SE/se-lib/AclQueryItems.php

@@ -0,0 +1,23 @@
+<?php
+
+class AclQueryItems {
+
+  public function __construct($acl) {
+    $this->_acl = $acl;
+    $this->_params = [];
+    $this->_source = 'default_db';
+  }
+  public function setParams($params) { $this->_params = $params; }
+  public function setSource($sourceName) { $this->_source = $sourceName; }
+  public function setRawSql($sql) { $this->_sql = $sql; }
+  public function fetchAll() {
+    return array_map(array($this, 'buildFeatureFromSqlRow'), DB::getPDO($this->_source)->fetchAll($this->_sql));
+  }
+  public function buildFeatureFromSqlRow($item) {
+    if (method_exists($this->_acl, 'buildFeatureFromSqlRow')) {
+      return $this->_acl->buildFeatureFromSqlRow($item, $this->_params);
+    }
+    return $item;
+  }
+
+}

+ 7 - 2
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -321,13 +321,18 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
       ? "limit {$limit} offset {$offset}"
       : '';
 
-    return array_map(array($this, 'buildFeatureFromSqlRow'), DB::getPDO()->fetchAll("
+    Lib::loadClass('AclQueryItems');
+    $query = new AclQueryItems($this);
+    $query->setParams($params);
+    $query->setSource('default_db');
+    $query->setRawSql("
       select t.*
       from `{$this->_rootTableName}` t
       {$sqlWhere}
       {$sqlOrderBy}
       {$sqlLimit}
-    "), $params);
+    ");
+    return $query->fetchAll();
   }
 
   public function buildFeatureFromSqlRow($item, $params = []) {