我正在尝试执行 PHP/MySQL 查询以选择一组列并清除特定记录的字段:
$sth = $dbh->query("SELECT column_name
FROM information_schema.columns
WHERE table_name = 'users'
AND column_name like '%_abc'");
$rows = $sth->fetchAll();
foreach ($rows as $row){
$sth = $dbh->prepare("UPDATE users
SET $row = NULL
WHERE user_id = $user_id");
$sth->execute();
}
但是,我收到以下错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]:
Column not found: 1054 Unknown column 'Array' in 'field list'
有任何想法吗?