php symfony doctrine或从2个表中获取数据

Since I'm very new don't judge me. I am trying to make a filter but there are some difficulties on the way. I have two tables of data. First with companies, second with users.

Companies:
____________________ 
id   | name        | 
1    | try         |                  
2    | test        |             
3    | experiment  |


Users:
_____________________________________
|id | company_id |  name   | status |
| 1 |      1     | Idiot   |pending |
| 2 |      1     | Funny   |active  |
| 3 |      2     | Me      |pending |
| 4 |      2     | Lucky   |rejected|
| 5 |      2     | Moon    |rejected|

I have to make perhaps INNER JOIN and take only companies and users that are pending. I'm not interested in 'rejected'. So I'm interested to get:

3  |  2  | Me | pending | test

and other record with pending and no active. The company must have pending user and the same company must not have active.

SELECT *
FROM users u
INNER JOIN companies c
ON u.company_id = c.id
WHERE u.status = 'pending'
  AND NOT EXISTS(SELECT u2.status 
                 FROM users u2 ON u2.id = c.id 
                 WHERE u2.status = 'pending')

or something like that was the SQL but I can't check it now. I want to make it Doctrine e.g. $query = ..->innerJoin(..)->where... but can't make it. Any help please. Oh and how would this handle 100,000 records database for example? Is there a better way? Thank you.

in /lib/model/doctine/UsersTable.class.php:

class UsersTable extends Doctrine_Table
{

  public function getAllCompanies($user_id) {

    $q = $this->createQuery('u')
      ->where('u.istatus = ?','pending')
      ->leftJoin('u.Companies c WITH c.id = u.company_id')
      ->execute();

    return $q;


  }
}