PDO - 在我的情况下,那个大的bindValue和bindParam

Yup... it's one of these.

Well, I am currently working on something that we can call a social network. I am using the Slim Framework with PDO and it's my very first job as well as my very first project. So, the problem is that I have a string in my Controller, but I want to pass it on to the model, but after it goes to the model( I've tested with print_r to see if it does pass and it does ) the bindParam doesn't seem to put it on the query.

The function would be this one:

    public static function obterTagsDasPessoas($ids)
{
    $container = getContainer();
    $query = $container->db->prepare("SELECT * FROM Pessoas_tags WHERE :ids");
    $query->bindParam(':ids', $ids, PDO::PARAM_STR);
    $query->execute();

    $result = $query->fetchAll();
    return $result;
}

I've tried changing to bindValue, since I saw that it is better for text. I don't know what's happening because it doesn't give any errors; it just doesn't seem to apply that bindParam and then procedes. Inside the $ids is id_Pessoas = 1 OR id_Pessoas = 4 which should complement the query up there. I've tried copying it to phpmyadmin and mySql and it gives me the expected results, it just doesn't work with that function.

Am I doing anything wrong? Thanks in advance.

I think you should send a single id such as 1 or 4 in your $ids parameter.

Then edit your query as

$query = $container->db->prepare("SELECT * FROM Pessoas_tags WHERE id_Pessoas=:ids");

I think this should work.