2
I have the following problem, when using the WHERE clause I am not able to use the values that are being passed by parameter.
As a return I have the following message:
- Pdostatement::execute(): SQLSTATE[HY093]: Invalid Parameter number: number of bound variables does not match number of tokens in*
TIPOS DE DADOS NO BANCO date tipo -> DATETIME municipio tipo -> INT entidade tipo -> INT
public function listLicitacoesEntidadesCidades($date, $municipio, $entidade){
$stmt = $this->pdo->prepare("
select
tab_licitacoes.id,
tab_licitacoes.cidade_id,
tab_licitacoes.entidade_id,
tab_licitacoes.data_abertura,
tab_licitacoes.data_cancelamento,
tab_licitacoes.status,
tab_licitacoes.modalidade,
tab_cidades.nome,
tab_entidades.nome_entidade
from tab_licitacoes
join
tab_cidades on (tab_licitacoes.cidade_id = tab_cidades.id)
join
tab_entidades on (tab_licitacoes.entidade_id = tab_entidades.id)
where
tab_licitacoes.status = 'A'
and
tab_licitacoes.data_cancelamento >= :date
and
tab_licitacoes.cidade_id = :municipio
and
tab_licitacoes.entidade_id = :entidade
");
$stmt->bindValue(':date', $date, PDO::PARAM_STR);
$stmt->bindValue(':municipio', $municipio, PDO::PARAM_INT);
$stmt->bindValue(':entidade', $entidade, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $data;
}
If you run this select directly in the database causes some error?
– Marco Souza
Passing fixed values on the 3 variables, example :pass municipality 34 returns exactly what I need
– Fbor