mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
improving acl perfomance
This commit is contained in:
parent
bb15271622
commit
ad678e3988
2 changed files with 9 additions and 9 deletions
|
@ -58,8 +58,8 @@ class DbAclSchema extends CakeSchema {
|
|||
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
|
||||
'indexes' => array(
|
||||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||||
'idx_acos_lft_rght' => array('column' => array('lft', 'rght'),'unique' => 0),
|
||||
'idx_acos_alias' => array('column' => 'alias','unique' => 0)
|
||||
'idx_acos_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0),
|
||||
'idx_acos_alias' => array('column' => 'alias', 'unique' => 0)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -76,8 +76,8 @@ class DbAclSchema extends CakeSchema {
|
|||
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
|
||||
'indexes' => array(
|
||||
'PRIMARY' => array('column' => 'id','unique' => 1),
|
||||
'idx_aros_lft_rght' => array('column' => array('lft', 'rght'),'unique' => 0),
|
||||
'idx_aros_alias' => array('column' => 'alias','unique' => 0)
|
||||
'idx_aros_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0),
|
||||
'idx_aros_alias' => array('column' => 'alias', 'unique' => 0)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class AclNode extends Model {
|
|||
'order' => $db->name("{$type}.lft") . ' DESC'
|
||||
);
|
||||
|
||||
$conditions_after_join = array();
|
||||
$conditionsAfterJoin = array();
|
||||
|
||||
foreach ($path as $i => $alias) {
|
||||
$j = $i - 1;
|
||||
|
@ -105,9 +105,9 @@ class AclNode extends Model {
|
|||
);
|
||||
|
||||
// it will be better if this conditions will performs after join operation
|
||||
$conditions_after_join[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id");
|
||||
$conditions_after_join[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght");
|
||||
$conditions_after_join[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft");
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id");
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght");
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft");
|
||||
|
||||
$queryData['conditions'] = array('or' => array(
|
||||
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght"),
|
||||
|
@ -115,7 +115,7 @@ class AclNode extends Model {
|
|||
);
|
||||
}
|
||||
|
||||
$queryData['conditions'] = array_merge($queryData['conditions'], $conditions_after_join);
|
||||
$queryData['conditions'] = array_merge($queryData['conditions'], $conditionsAfterJoin);
|
||||
|
||||
$result = $db->read($this, $queryData, -1);
|
||||
$path = array_values($path);
|
||||
|
|
Loading…
Reference in a new issue