我通常在我的网站上使用mysql数据库,但我试图了解更多关于oracle的信息。。。我的代码在2天前工作,但现在它给出了一条错误消息,例如ORA编号这是我的数据库字段
KODE_GUDANG CHAR
GUDANG CHAR
LASTUPDATE CHAR
KODE_UNIT CHAR
NOMER_REKJURNAL CHAR
KODE_GUDANG_KREDIT CHAR
这是我查询的型号
function getDataOneColumn($getCol, $table, $column, $id) {
return $this->db->query("SELECT $getCol as val FROM $table WHERE $column = $id")->row_array();
}
这是针对我的控制器,它给出了一个错误:ORA-01722
$this->data['no_rek'] = ($this->data['no_rek'] =='')?$this->m_dao->getDataOneColumn("NOMER_REKJURNAL","TBL_MASTER_GUDANG","KODE_GUDANG",$this->data['kode_gdg'])['VAL']:$this->data['no_rek'];
在那之后,我阅读了文献摘要,它的意思是">您执行了一个SQL语句,该语句试图将字符串转换为数字">
我试着把我的代码改成
$this->data['no_rek'] = ($this->data['no_rek'] =='')?$this->m_dao->getDataOneColumn("NOMER_REKJURNAL","TBL_MASTER_GUDANG","KODE_GUDANG",'"'.$this->data['kode_gdg'])['VAL'].'"':"'".$this->data['no_rek']."'";
这一个给出了另一个ORA错误,ORA-01756。其手段">您试图执行一个包含未被两个单引号包围的字符串的语句">
新错误
Error Number: 1722
ORA-01722: invalid number
SELECT NOMER_REKJURNAL as val FROM TBL_MASTER_GUDANG WHERE KODE_GUDANG = 04
Filename: C:/xampp/htdocs/formula/system/database/DB_driver.php
Line Number: 691
有人能告诉我为什么我的代码在2天后出现错误吗?和如何解决此错误?谢谢
在阅读了大量带有ORA错误的帖子后,我可以解决我的问题。我只需要添加"$val.">
$this->data['no_rek'] = ($this->data['no_rek'] =='')?$this->m_dao->getDataOneColumn("NOMER_REKJURNAL","TBL_MASTER_GUDANG","KODE_GUDANG","'".$this->data['kode_gdg']."'")['VAL']:$this->data['no_rek'];