|
@@ -367,6 +367,49 @@ class AclQueryFeatures {
|
|
|
");
|
|
");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ DBG::log($this->_query, 'array', "TODO: optimize \$this->_query");
|
|
|
|
|
+ $this->_USE_TEMPORARY_TABLE = false; // TODO: ...
|
|
|
|
|
+ if ($this->_USE_TEMPORARY_TABLE) {
|
|
|
|
|
+ $sortBy = ($this->hasParam('sortBy')) ? $this->getParam('sortBy') : null;
|
|
|
|
|
+ if (!$sortBy) {
|
|
|
|
|
+ $sortBy = $this->hasParam('order_by')
|
|
|
|
|
+ ? ( $this->hasParam('order_dir')
|
|
|
|
|
+ ? $this->getParam('order_by') . " " . $this->getParam('order_dir')
|
|
|
|
|
+ : $this->getParam('order_by')
|
|
|
|
|
+ )
|
|
|
|
|
+ : '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $TMP_TABLE_NAME = $this->_acl->getRootTableName() . "__#TEMPORARY";
|
|
|
|
|
+ DBG::log("\$TMP_TABLE_NAME='{$TMP_TABLE_NAME}'");
|
|
|
|
|
+ Lib::loadClass('AntAclBase');
|
|
|
|
|
+ if ($this->_acl instanceof AntAclBase) {
|
|
|
|
|
+ $baseSql = $this->_query->generateSql();
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ create temporary table `{$TMP_TABLE_NAME}`
|
|
|
|
|
+ {$baseSql}
|
|
|
|
|
+ ");
|
|
|
|
|
+ DBG::log(DB::getPDO()->fetchValue("select count(*) as cnt from `{$TMP_TABLE_NAME}`"), 'array', "select count(*) cnt from '{$TMP_TABLE_NAME}'");
|
|
|
|
|
+
|
|
|
|
|
+ $tmpAclFrom = clone($this->_acl);
|
|
|
|
|
+ $tmpAclFrom->_rootTableName = $TMP_TABLE_NAME;
|
|
|
|
|
+ // $tmpAclFrom = AntAclBase::buildInstance($this->_acl->getID(), [
|
|
|
|
|
+ // 'name' => $this->_acl->getName(),
|
|
|
|
|
+ // '_rootTableName' => $TMP_TABLE_NAME,
|
|
|
|
|
+ // 'idDatabase' => $this->_acl->getDatabaseID(),
|
|
|
|
|
+ // 'namespace' => $this->_acl->getNamespace(),
|
|
|
|
|
+ // 'primaryKey' => $this->_acl->getPrimaryKeyField(),
|
|
|
|
|
+ // 'field' => $this->_acl->getFields(),
|
|
|
|
|
+ // ]);
|
|
|
|
|
+ Lib::loadClass('AclQueryBuilder');
|
|
|
|
|
+ $query = new AclQueryBuilder();
|
|
|
|
|
+ $query->from($tmpAclFrom, $prefix = 't');
|
|
|
|
|
+ DBG::log($query, 'array', "TODO: \$query by temporary table");
|
|
|
|
|
+ // $this->_query = $query;
|
|
|
|
|
+ // return $this->_query;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
return clone($this->_query);
|
|
return clone($this->_query);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -403,7 +446,7 @@ class AclQueryFeatures {
|
|
|
|
|
|
|
|
$select = $this->prepareSelect();
|
|
$select = $this->prepareSelect();
|
|
|
DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
|
- DBG::log($this->getQuery(), 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).") \$this->getQuery()");
|
|
|
|
|
|
|
+ // DBG::log($this->getQuery(), 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).") \$this->getQuery()");
|
|
|
|
|
|
|
|
return $this->fetchRowsRefs(
|
|
return $this->fetchRowsRefs(
|
|
|
$this->getQuery()
|
|
$this->getQuery()
|