0
function get_employees_by_hierarchy( $_employee_id = 0, $_dept = 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_manger_id = " .$this->dbh->quoteSmart( $employee_id );
}
$_result = $this->query( $_query );
while ( $_row = $_result->fetchRow() ) {
$_row = $_depth;
array_push( $_org_array, $_row );
$_org_array = $this->get_employees_by_hierarchy(
$_row ,
$_depth,


$_org_array );
}
return $_org_array;
}

Edited by happygeek: fixed formatting

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by BrettH
1

Also, if you are having issues with it, I noticed that $_depth is mispelt in your parameters.

function get_employees_by_hierarchy( $_employee_id = 0, $_depth= 0, $_org_array = array() ) {

So if it's not working, try adding the H I highlighted in red.

Votes + Comments
Good eye. Welcome to daniweb!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.