PHP PDO在函数中执行

I've created this class:

class  data
{
public function del($cat, $id)
{
    global $dbh;

    $del = $dbh->prepare("DELETE FROM :cat WHERE id = :id");
    $del->bindParam(":cat",$cat);
    $del->bindParam(":id", $id);
    $del->execute();
}
}

And I'm running into an issue with binding the

:cat

variable to the statement, if I don't use bindParam for

:cat

and just tell it which table I want it to delete it from, for example:

$del = $dbh->prepare("DELETE FROM table1 WHERE id = :id");

It works fine.

I know it has to be some stupid error, but I can't for the life of me figure it out.

It seems what you're trying to do is simply not possible

Using table as parameter name is not possible with PDO.

Stack overflow post

php.net post