|
|
@@ -253,8 +253,11 @@ class AclQueryFeatures {
|
|
|
public function getQuery() {
|
|
|
if ($this->_query) return $this->_query;
|
|
|
// $ds = $this->_acl->getDataSource(); // TODO: only for TableAcl // TODO: move _parseSqlWhere to this class
|
|
|
- $filtrIsInstance = [];
|
|
|
+ $filtrIsInstance = []; // $filtrIsInstance = [ $this->_acl->getNamespace() ];
|
|
|
$filtrIsNotInstance = [];
|
|
|
+ if (!empty($this->_params['f_is_instance'])) $filtrIsInstance = $this->_params['f_is_instance'];
|
|
|
+ if (!empty($this->_params['f_is_not_instance'])) $filtrIsNotInstance = $this->_params['f_is_not_instance'];
|
|
|
+
|
|
|
$this->_query = ACL::query($this->_acl)
|
|
|
->isInstance($filtrIsInstance)
|
|
|
->isNotInstance($filtrIsNotInstance);
|
|
|
@@ -266,6 +269,10 @@ class AclQueryFeatures {
|
|
|
if (is_int($k) && is_array($v)) {
|
|
|
$this->_query->where($v); // TODO: check format [$fieldName, $comparisonSign, $value]
|
|
|
} else if (is_int($k) && null === $v) { // skip NULL
|
|
|
+ } else if ('f_is_instance' === $k) { // parsed before
|
|
|
+ } else if ('f_is_not_instance' === $k) { // parsed before
|
|
|
+ } else if ('@instances' === $k) { // skip - select
|
|
|
+ } else if ('cols' === $k) { // skip - select
|
|
|
} else if ('f_' === substr($k, 0, 2) && is_string($v) && strlen($k) > 3) {
|
|
|
$fieldName = substr($k, 2);
|
|
|
$fieldType = $this->_acl->getXsdFieldType($fieldName);
|
|
|
@@ -333,13 +340,27 @@ class AclQueryFeatures {
|
|
|
$offset = V::get('limitstart', 0, $this->_params, 'int');
|
|
|
|
|
|
DBG::log(['params' => $this->_params, 'sortBy' => $sortBy, 'limit' => $limit, 'offset' => $offset], 'array', '$this->_params');
|
|
|
+
|
|
|
+ // TODO: select from params: 'cols' => [ fieldName, ... ]
|
|
|
+ // TODO: select from params: '@instances' => 1
|
|
|
+ // TODO: if no fields set, then '*'
|
|
|
+ // TODO: select must contain primaryKey
|
|
|
+ $select = [];
|
|
|
+ $select = [
|
|
|
+ 'rawSelect' => ($this->_acl instanceof TableAcl)
|
|
|
+ ? $this->_acl->getDataSource()->_getSqlCols()
|
|
|
+ : '*'
|
|
|
+ ];
|
|
|
+ if (!empty($this->_params['@instances'])) $select[] = '@instances';
|
|
|
+ if (!empty($this->_params['cols'])) {
|
|
|
+ foreach ($this->_params['cols'] as $fieldName) {
|
|
|
+ $select[] = $fieldName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DBG::log($select, 'array', "\$select is(TableAcl)=(".($this->_acl instanceof TableAcl).")");
|
|
|
+
|
|
|
return $this->getQuery()
|
|
|
- ->select([
|
|
|
- 'rawSelect' => ($this->_acl instanceof TableAcl)
|
|
|
- ? $this->_acl->getDataSource()->_getSqlCols()
|
|
|
- : '*'
|
|
|
- ])
|
|
|
- ->select(!empty($this->_params['@instances']) ? '@instances' : null)
|
|
|
+ ->select($select)
|
|
|
->limit($limit)
|
|
|
->offset($offset)
|
|
|
->orderBy($sortBy)
|