0

我有我公司的发票脚本,我现在对 PHP 有一点了解(尤其是操作现有文件)并且脚本的程序员不再可用,所以我决定用报价列表扩展脚本。这与发票脚本完全相同,只是它使用不同的表。

现在我收到错误:

发生数据库错误
错误号:1054
'on 子句'中的未知列 'customer'

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
4

1 回答 1

0

有问题。我刚刚意识到我在数据库中犯了一个错字。我写为列名:客户而不是客户。

感谢大家的帮助!

于 2013-11-08T19:33:29.900 回答