|
@@ -385,7 +385,13 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
foreach ($cols as $fieldXPath) {
|
|
foreach ($cols as $fieldXPath) {
|
|
|
- if (false === strpos($fieldXPath, '/')) {// not xpath - field name
|
|
|
|
|
|
|
+ if ('@' == substr($fieldXPath, 0, 1)) {// attr
|
|
|
|
|
+ if ('@instance' === $fieldXPath) {
|
|
|
|
|
+ $filterCols['@instance'] = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new Exception("Not implemented attribute name '{$fieldXPath}' in '{$this->_namespace}'");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (false === strpos($fieldXPath, '/')) {// not xpath - field name
|
|
|
if (!array_key_exists($fieldXPath, $this->_simpleSchema['root'])) throw new Exception("Field name '{$fieldXPath}' not exists in '{$this->_namespace}'");
|
|
if (!array_key_exists($fieldXPath, $this->_simpleSchema['root'])) throw new Exception("Field name '{$fieldXPath}' not exists in '{$this->_namespace}'");
|
|
|
$field = $this->_simpleSchema['root'][$fieldXPath];
|
|
$field = $this->_simpleSchema['root'][$fieldXPath];
|
|
|
if (!empty($field['@type'])) {
|
|
if (!empty($field['@type'])) {
|
|
@@ -406,6 +412,18 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
$object = [];
|
|
$object = [];
|
|
|
$filterCols = $this->getParamCols($params);
|
|
$filterCols = $this->getParamCols($params);
|
|
|
$object['_raw'] = $row;
|
|
$object['_raw'] = $row;
|
|
|
|
|
+ if (in_array('@instance', $filterCols)) {
|
|
|
|
|
+ $instanceTable = Core_AclHelper::getInstanceTable($this->getRootTableName());
|
|
|
|
|
+ $sqlPkFieldName = $this->getSqlPrimaryKeyField();
|
|
|
|
|
+ if (empty($row[$sqlPkFieldName])) throw new Exception("Missing primary key in ({$this->_namespace})");
|
|
|
|
|
+ $sqlPk = DB::getPDO()->quote($row[$sqlPkFieldName], PDO::PARAM_STR);
|
|
|
|
|
+ $object['@instance'] = DB::getPDO()->fetchValue("
|
|
|
|
|
+ select i.INSTANCE_NAME
|
|
|
|
|
+ from `{$instanceTable}` i
|
|
|
|
|
+ where i.PRIMARY_KEY = {$sqlPk}
|
|
|
|
|
+ ");// TODO: where i.`INSTANCE_TYPE` = 'instance' -- (i.`INSTANCE_TYPE` != 'derived')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
|
|
foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
|
|
|
if ('@' == substr($fieldName, 0, 1)) continue;
|
|
if ('@' == substr($fieldName, 0, 1)) continue;
|
|
|
if (!array_key_exists($fieldName, $filterCols)) continue;// only filter cols
|
|
if (!array_key_exists($fieldName, $filterCols)) continue;// only filter cols
|