Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
errors mesage:
SQLSTATE[HY093] : numéro de paramètre non valide : le nombre de variables liées ne correspond pas au nombre de jetons


What I have tried:

code:
    public function findByIdForInfoClient($id){
    $query = $this->pdo->prepare(
      "SELECT p.*, c.depot, c.retrait, c.caisse
      FROM post
      JOIN comptes c
      ON p.id = c.client_id
      WHERE p.id =c.client_id");
    $query->execute(array(':id' => $id));
    $query->setFetchMode(PDO::FETCH_CLASS, $this->class);
    $result = $query->fetch();
    return $result;
}
Posted
Updated 3-Apr-22 17:35pm

1 solution

You are using p as alias in your query but p is missing in FROM post p. Use the following query:

code
public function findByIdForInfoClient($id){
    $query = $this->pdo->prepare(
      "SELECT p.*, c.depot, c.retrait, c.caisse
      FROM post p
      JOIN comptes c
      ON p.id = c.client_id
      WHERE p.id =c.client_id");
    $query->execute(array(':id' => $id));
    $query->setFetchMode(PDO::FETCH_CLASS, $this->class);
    $result = $query->fetch();
    return $result;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900