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;
}

Recommended Answers

All 2 Replies

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.

commented: Good eye. Welcome to daniweb! +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.