我的公司有一个发票脚本,我现在对 PHP 有一点了解(尤其是操作现有文件),并且该脚本的程序员不再可用,因此我决定使用报价列表来扩展该脚本。这与发票脚本的工作方式完全相同,只是它使用不同的表。
现在我收到错误:
A Database Error Occurred
Error Number: 1054
Unknown column 'customer' in 'on clause'
SELECT idofferte,noofferte,CONCAT(namecustomer,' ',lastname)
customer,DATE_FORMAT(dateofferte,'%d/%m/%Y')dateofferte,
(SELECT SUM(pu*duration)
FROM service2
WHERE offerte=idofferte
) subtotal,discount,btw,transport,material
FROM offerte
INNER JOIN customer ON idcustomer=customer
WHERE 1=1
ORDER BY CAST(SUBSTR(noofferte,9) AS UNSIGNED) DESC
LIMIT 0,25
原始脚本(用于发票):
function ilist( $start = 0, $limit = 25, $pattern = '' ) {
$where = 'WHERE 1=1';
if( '' != $pattern )
$where .= " AND namecustomer LIKE '$pattern%' OR lastname LIKE '$pattern%'";
return $this->db->query( "SELECT idinvoice,noinvoice,CONCAT(namecustomer,' ',lastname) customer,DATE_FORMAT(dateinvoice,'%d/%m/%Y')dateinvoice,(SELECT SUM(pu*duration) FROM service WHERE invoice=idinvoice)subtotal,discount,btw,transport,material FROM invoice INNER JOIN customer ON idcustomer=customer $where ORDER BY CAST(SUBSTR(noinvoice,9) AS UNSIGNED) DESC LIMIT $start,$limit" )->result_array();
}
我的脚本(用于优惠):
function ilist( $start = 0, $limit = 25, $pattern = '' ) {
$where = 'WHERE 1=1';
if( '' != $pattern )
$where .= " AND namecustomer LIKE '$pattern%' OR lastname LIKE '$pattern%'";
return $this->db->query( "SELECT idofferte,noofferte,CONCAT(namecustomer,' ',lastname) customer,DATE_FORMAT(dateofferte,'%d/%m/%Y')dateofferte,(SELECT SUM(pu*duration) FROM service2 WHERE offerte=idofferte)subtotal,discount,btw,transport,material FROM offerte INNER JOIN customer ON idcustomer=customer $where ORDER BY CAST(SUBSTR(noofferte,9) AS UNSIGNED) DESC LIMIT $start,$limit" )->result_array();
}
我的脚本和原始脚本之间的区别在于表格。 我该如何解决这个错误?
注意:该错误当然不会出现在原始脚本中。
提前致谢!
编辑: 表格:
-------------------------------
Invoice
-------------------------------
idinvoice
noinvoice
costumer
dateinvoice
discount
btw
transport
material
employee
creation
-------------------------------
Offerte
-------------------------------
idofferte
noofferte
customer
dateofferte
subjectofferte
discount
btw
transport
material
employee
creation
-------------------------------
customer
-------------------------------
idcustomer
namecustomer
lastname
address
number
zip
city
phone
email
-------------------------------
service
-------------------------------
idservice
dateservice
description
duration
pu
invoice
-------------------------------
service2
-------------------------------
idservice
dateservice
description
duration
pu
offerte
最佳答案
遇到问题了。 我刚刚意识到我在数据库中犯了一个错字。 我写为列名:Costumer 而不是 customer。
感谢大家的帮助!
关于php - 'customer' 中的未知列 'on clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19864645/