PHP, adobe, sqlite3和AutoExecute返回错误5 (SQLITE_BUSY)


PHP, Adodb, sqlite3 and AutoExecute returns error 5 (SQLITE_BUSY)

我有一个小问题。我尝试使用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和自动执行?

见https://github.com/ADOdb/ADOdb/issues/286:

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

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

作为旁注,由于autoExecute()的开销,使用预处理语句可能更有效。