【发布时间】:2019-06-21 15:54:18
【问题描述】:
我正在编写如下所示的 php 代码:
class MyDB extends SQLite3
{
function __construct()
{
$this->open('database/Podcast.db');
}
}
$db = new MyDB();
$f = $mp4_files[$_POST['id']];
$parts = pathinfo($f);
switch ($parts['extension']) {
/* Conversion of mp4 into mp3 is happening */
}
print_r($f); // Line Z
$result = $db->exec("UPDATE Podcast_Export SET Status = 'Completed' WHERE House_number = '" . $f . "'"); // Line A
if ($result == FALSE) {
echo "Error in fetch " . $db->lastErrorMsg(); // Line M
}
在 Z 行,在控制台上会打印 36031P.mp4(当从 第一个表格行(从 UI)中单击“Go”按钮时 )
在 Z 行,在控制台上打印 hello.mp4(当从 第 2 表行(从 UI)单击“Go”按钮时)
问题陈述:
我在 A 行有一个查询以更新 Podcast_Export 表,但它不工作并在 M 行抛出错误:
Error in fetch database is locked
此时,我在 Podcast_Export 表中有以下内容:
我使用的SQLite版本是3.27.2
【问题讨论】:
-
问题是,提交后你会在哪里使用这些值?
data-id="<?php echo $key; ?>"没用,如果你只是使用 PHP -
这是个好问题。我认为我的代码中有一个小错误。请记住,当新的
mp4 files进入目录时,Podcast_Export表中的状态应该是Go,我们添加了以下查询:foreach ($mp4_files as $value) { $count = $db->querySingle("SELECT COUNT(*) as count FROM Podcast_Export WHERE House_number = '".$value."'"); if($count <= 0){ $db->exec("INSERT INTO Podcast_Export (House_number,Status) VALUES ('".$value."', 'Go')"); } }当 mp4 文件转换为 mp3 时,状态应该在里面完成Podcast_Export 表。 -
它很难理解..你必须分享完整的例子
-
@devpro 我已经更新了我的问题。让我知道如何解决该错误。
-
@flash 尝试在脚本末尾添加
$db->close();和unset($db);以释放附加数据库文件上的操作系统文件锁定,也许这是你的问题。