I am trying to execute a PHP/MySQL query to select a set of columns and clear the fields for a particular record:
$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();
}
However, I am getting the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]:
Column not found: 1054 Unknown column 'Array' in 'field list'
Any ideas?
Your
$rowis an array. TryYou can look at
$rowusing: