I made a report using a quick form to set parameters. There's a multi-select field to select one or more users. Here's the problem code when the form is submitted and the report is processed.
} else if ($data = $mform->get_data()) {
...
$learnername = $DB->get_records_select('user', 'id IN (?)', array($data->learner));
...
}
This produces an error:
Debug info: ERROR: invalid input syntax for integer: "Array"
SELECT * FROM mdl_user WHERE id IN ($1)
[array (
0 =>
array (
0 => '81',
1 => '21',
2 => '2',
),
)]
Error code: dmlreadexception
I can get rid of the error by removing the outer array, like this:
$learnername = $DB->get_records_select('user', 'id IN (?)', $data->learner);
But when I do this, $learnername always contains the first user selected only. I need it to handle as many users as were selected. Any ideas?