1

あるテーブル (パーティ) の各行にすべての列を使用し、別のテーブル (顧客) のいくつかの列を使用しようとしています。

わかりました、これが私のコードです

public function getParty($data = array()) {

    $sql = "SELECT party.* , customer.customer_id AS customerID, customer.firstname AS customerFN, customer.lastname AS customerLN, customer.email AS customerEMAIL, customer.ip AS cutomerIP
    FROM `" . DB_PREFIX . "party` 
    JOIN `" . DB_PREFIX . "cutomer` 
    ON party.cutomer_id = customer.customer_id
    WHERE status=3";

    $sort_data = array(


        'date_added',
        'order_id',
        'customer_id',
        'customerFN',
        'customerLN',
        'customerEMAIL',
        'customerIP',
        'description',
        'status',
        'amount'


    );

    if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
        $sql .= " ORDER BY " . $data['sort'];   
    } else {
        $sql .= " ORDER BY date_added"; 
    }

    if (isset($data['order']) && ($data['order'] == 'DESC')) {
        $sql .= " DESC";
    } else {
        $sql .= " ASC";
    }

    if (isset($data['start']) || isset($data['limit'])) {
        if ($data['start'] < 0) {
            $data['start'] = 0;
        }           

        if ($data['limit'] < 1) {
            $data['limit'] = 20;
        }   

        $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
    }

    $query = $this->db->query($sql);

    return $query->rows;
}

そして、ここにエラーがあります

Notice: Error: Table 'XXX.cutomer' doesn't exist
Error No: 1146
SELECT party.* , customer.customer_id AS customerID, customer.firstname AS customerFN, customer.lastname AS customerLN, customer.email AS customerEMAIL, customer.ip AS cutomerIP FROM `party` JOIN `cutomer` ON party.cutomer_id = customer.customer_id WHERE status=3 ORDER BY date_added ASC LIMIT 0,10 in /srv/www/htdocs/XXX/system/database/mysql.php on line 49

多分私はどこかで間違っているかもしれませんが、それを見ません

ごあいさつ ペタル・ストヤノフ

4

4 に答える 4

1
JOIN `" . DB_PREFIX . "cutomer` 

する必要があります

JOIN `" . DB_PREFIX . "customer` 

?

また...

ON party.cutomer_id = customer.customer_id

する必要があります

ON party.customer_id = customer.customer_id

?

のすべてのインスタンスを検索し、cutomerそれらを に置き換えますcustomer

于 2012-11-01T12:22:05.247 に答える
0

から変更してください

    JOIN `" . DB_PREFIX . "cutomer` 

    JOIN `" . DB_PREFIX . "customer` 

元:

    FROM `" . DB_PREFIX . "party` 
    JOIN `" . DB_PREFIX . "customer` 
    ON party.cutomer_id = customer.customer_id
    WHERE status=3";
于 2012-11-01T12:26:01.130 に答える
0

そうあるべきだと思う

ON party.customer_id = customer.customer_id

それ以外の

ON party.cutomer_id = customer.customer_id
于 2012-11-01T12:22:20.113 に答える
-1

SQL stmt を次のように変更します。

$sql = "SELECT party.* , customer.customer_id AS customerID, customer.firstname AS customerFN, customer.lastname AS customerLN, customer.email AS customerEMAIL, customer.ip AS customerIP
FROM `" . DB_PREFIX . "party` 
JOIN `" . DB_PREFIX . "customer` 
ON party.customer_id = customer.customer_id
WHERE status=3";
于 2012-11-01T12:23:52.747 に答える