php - 工作 1 年以上后突然出现 SQL 语法错误 - 未升级
问题描述
一年来,我公司的软件运行良好。突然发生这种情况(并且让我们付出了很多头痛和金钱):
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);
}
伴奏AlunoDao.php:
parent::select($sql, $args);
伴奏AlunoBo.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);
奇怪的是它工作了一年多,我看不出它有什么问题。它怎么会突然出现语法错误?
解决方案
推荐阅读
- java - 如何从mysql数据库中创建和访问项目行的arraylist(在java中)?
- dart - 如何仅在按下按钮时调用方法?
- css - 有一个滚动条,但没有什么可看的
- php - Laravel 服务容器 - 注册一个共享给所有服务的对象
- mysql - 不显示表格行
- r - 如何索引列表的第一个元素,并将其应用于 R 中数据帧的每一行?
- c - 为什么链表不在主函数中打印?
- ios - 从(英语到阿拉伯语)更改语言时如何从左到右更改 SWRaveal 侧菜单表单
- tabs - 即使在 Visual Studio 2017 中取消注释后,如何保持制表符缩进?
- python - 如何在 python 代码脚本中编码密码?