phpsymfonydoctrinedoctrine-1.2orange

Doctrine 1.2 query with array bind


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?


Solution

  • 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.