Hi guys!
I create my system in PHP 5.6, but deploy it in PHP 7.0.
I’m getting Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘Aluno.id_auto_escola’ in ‘where clause’ when I try to get data in my hasOne query.
I’m very mess bacause this error appears in just one use case, in all other times the function works fine.
my call:
$aluno = TableRegistry::get(‘aluno’)
->getAlunos(
$idAutoEscola,
$idAluno,
‘S’
)[0];
my getAlunos method:
public function getAlunos($idAutoEscola, $idAluno = null, $isAtivo = null, $nomeCpf = null) {
$aluno = $this->find('all', ['contain' => ['Parcelamento', 'Parcelamento.Parcelas', 'AutoEscola', 'Categori', 'TpProcesso', 'FmPagamento']])
->where(['Aluno.id_auto_escola' => $idAutoEscola]);
if(!empty($idAluno)) $aluno->where(['Aluno.id_aluno' => $idAluno]);
if(!empty($isAtivo)) $aluno->where(['Aluno.is_ativo' => $isAtivo]);
if(!empty($nomeCpf))
$aluno->where(['OR' => [
'nome LIKE' => '%' . $nomeCpf . '%',
'cpf' => $nomeCpf
]]);
$aluno->order(['nome']);
$aluno = $aluno->toList();
foreach($aluno as $a) {
$this->setStatusPagamento($a);
}
return $aluno;
}
What can I do solve this problem?
Thanks!