1

我有一个小问题。我尝试使用 AutoExecute 执行几个查询:

$rows = array(
    array(
        "text" => md5(rand(1,999)),
        "value" => rand(1,999)
    ),
    array(
        "text" => md5(rand(1,999)),
        "value" => rand(1,999)
    ),
    array(
        "text" => md5(rand(1,999)),
        "value" => rand(1,999)
    )
    /* [... and 10 more ...] */
);

foreach ($rows as $row)
{
    if ($db->AutoExecute("sometable", $row, "INSERT"))
    {
        echo "Done";
    }
    else
    {
        echo "Error";
    }
}
?>

我得到错误代码 5。如何使用 Adodb 和 AutoExecute 处理多个查询?

4

1 回答 1

0

https://github.com/ADOdb/ADOdb/issues/286中所述:

autoExecute() 只处理一条记录。尝试

foreach($sql as $row) {
    $db->autoExecute('test', $row, 'INSERT');
}

附带说明一下,由于 autoExecute() 的开销,使用准备好的语句执行此操作可能更有效。

于 2016-11-08T09:12:13.357 回答