Doctrine 1.2 query with array bind

192 Views Asked by At

I have this code:

$query = Doctrine_Query::create()
        ->select('*')
        ->from('attendanceRecord a')
        ->where("employeeId IN (?)", implode(",", $employeeId));

$employeeId is an array of numbers

The sql output was:

Select * from attendanceRecord a where employeeId IN ('2,4,5')

but it have quote and was wrong I want this:

Select * from attendanceRecord a where employeeId IN (2,4,5)

How can I do it correctly in doctrine?

1

There are 1 best solutions below

1
Mike Doe On BEST ANSWER

As simple as:

$query = Doctrine_Query::create()
  ->from('attendanceRecord a')
  ->whereIn('a.employeeId', $employeeId);

Please make sure you see the official documentation before asking a question.