工作1年以上后突然出现SQL语法错误-无法升级

时间:2018-09-28 02:11:32

标签: php sql syntax

我公司的软件运行了一年很好。突然之间,这种情况发生了(并且使我们付出了很多头痛和金钱):

    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

堆栈跟踪:

#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

堆栈中提到的文件中的代码(以**开头和结尾的行是堆栈跟踪中提到的确切代码,我现在添加了这些,供大家查看):

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);

奇怪的是,它已经工作了一年多,而我看不出有什么问题。它怎么会出现语法错误?

0 个答案:

没有答案