SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function get_employees_by_hierarchy( $_employee_id = 0,$_depth = 0,$_org_array = array() ) {
  4.     if ( $this->org_depth < $_depth ) {
  5.         $this->org_depth = $_depth;
  6.     }
  7.  
  8.     $_depth++;
  9.     $_query = "SELECT * FROM employees WHERE ";
  10.     if ( !$_employee_id ) {
  11.         $_query .= "employee_manager_id IS NULL OR employee_manager_id = 0";
  12.     } else {
  13.         $_query .= "employee_manager_id = " . $this->dbh->quoteSmart( $_employee_id );
  14.     }
  15.  
  16.     $_result = $this->query( $_query );
  17.  
  18.     while ( $_row = $_result->fetchRow() ) {
  19.         $_row['depth'] = $_depth;
  20.         array_push( $_org_array, $_row );
  21.         $_org_array = $this->get_employees_by_hierarchy(
  22.                         $_row['employee_manager_id'],
  23.                         $_depth,
  24.                         $_org_array
  25.                         );
  26.     }
  27.  
  28.     return $_org_array;
  29. }
  30.  
  31. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top