我是新来的,我觉得很迷茫。这段代码是在做无限循环吗?
我应该删除第2-4行吗?第19行“$_row‘’employee_manager_id‘”是否很重要?
我该怎么做有什么建议吗?谢谢。
function get_employees_by_hierarchy( $_employee_id = 0,$_depth = 0,$_org_array = array() ) {
if ( $this->org_depth < $_depth ) {
$this->org_depth = $_depth;
}
$_depth++;
$_query = "SELECT * FROM employees WHERE ";
if ( !$_employee_id ) {
$_query .= "employee_manager_id IS NULL OR employee_manager_id = 0";
}
else {
$_query .= "employee_manager_id = " . $this->dbh->quoteSmart( $_employee_id );
}
$_result = $this->query( $_query );
while ( $_row = $_result->fetchRow() ) {
$_row['depth'] = $_depth;
array_push( $_org_array, $_row );
$_org_array = $this->get_employees_by_hierarchy(
$_row['employee_manager_id'],
$_depth,
$_org_array
);
}
return $_org_array;
}发布于 2013-12-05 00:28:51
从外观上看:
它做了一个无限循环。,,
$_org_array = $this->get_employees_by_hierarchy( $_row['employee_manager_id'], $_depth, $_org_array );
不运行,或者至少将它分配给不是get_employees_by_hierarchy的东西。
在你修复这个问题之后,如果一个员工是他们自己在某个point.
$_org_array’字段的深度,但我们无法查看是否使用了该字段。它当然没有破坏代码中的任何东西,,
$_org_array之前,
$_org_array = $this.https://stackoverflow.com/questions/20380357
复制相似问题