For 1 year my company's software worked just fine. Out of the sudden this happens (And is costing us a lot of headache and money):
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'get FROM Acompanhamento WHERE alunoid = '2767'
and excluido = 0 ORDER BY data de' at line 1' in /.../dao/DboObject.php:27
Stack trace:
#0 /.../DboObject.php(27): PDOStatement->execute(Array)
#1 /.../AcompanhamentoAlunoDao.php(24): DboObject->select('SELECT id, peso...', Array)
#2 /.../AcompanhamentoAlunoBo.php(19): AcompanhamentoAlunoDao->select('alunoid = ? and...', Array)
#3 /.../ficha_de_acompanhamento.php(38): AcompanhamentoAlunoBo->getAcompanhamentoByAluno('2767')
#4 {main}
thrown in /.../DboObject.php on line 27
Code in the files mentioned by the stack (lines that start and end with ** are the exact ones mentioned by the stack trace and I added that now for you guys to see):
DboObject.php:
public function select($sql='',$args){
$this->query = $this->pdo->prepare($sql);
**$this->query->execute($args);**
$this->result = $this->query->fetchAll(PDO::FETCH_OBJ);
}
AcompanhamentoAlunoDao.php:
parent::select($sql, $args);
AcompanhamentoAlunoBo.php:
public function getAcompanhamentoByAluno($alunoId,$campo=null){
**$query = "alunoid = ? and excluido = 0 ";**
if(!is_null($campo)){
$query.= "and ".$campo." is not null ";
}
ficha_de_acompanhamento.php:
$acompanhamento = $acompanhamentoAlunoBo->getAcompanhamentoByAluno($AlunoId);
What's weird is that it worked for more then a year and I can't see nothing wrong with it. How can it have a syntax error out of nowhere?