使用PDO进行多插入时的基数违规

I am attempting to run the following query which is a multi insert. Everything seems fine but it throws this error:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

My code is as follows

$report_categories=array(1,2,3);
$report_categories=array_unique($report_categories);    
$rowPlaces = '(' . implode(', ', array_fill(0, 2, '?')) . ')';
$allPlaces = implode(', ', array_fill(0, count($report_categories), $rowPlaces));

$add_report_types=$this->prepare("
    INSERT INTO report_types (
        report_id,
        category
    ) VALUES (
        " . $allPlaces . "
    )");

$i=1;
foreach($report_categories as $category_id){
    $add_report_types->bindValue($i, $report_id, PDO::PARAM_INT);
    $i++;
    $add_report_types->bindValue($i, $category_id, PDO::PARAM_INT);
    $i++;
}
$add_report_types->execute();

You might want to try it without the parentheses in the values part of your query:

$add_report_types=$this->prepare("
    INSERT INTO report_types (
        report_id,
        category
    ) VALUES " . $allPlaces);

If I understand it right, $allPlaces should contain a string that looks like this:

(?, ?), (?, ?), (?, ?)

So you want your query to look like:

INSERT INTO report_types (
    report_id,
    category
) VALUES (?, ?), (?, ?), (?, ?);

http://dev.mysql.com/doc/refman/5.5/en/insert.html