我尝试将此查询转换为CodeIgniter,但我只是一个初学者。我发现如何转换简单的SQL,但这段代码对我来说太难了。有没有人可以帮助我将此代码转换为CodeIgniter?
SELECT
cm.customerID,cm.customerName, cm.phone,adr.address,
adr.city, adr.zipcode,
bd.bookingDate,bd.startBooking,
bd.endBooking, pt.type
FROM
customers cm, addresses adr, bookings bd, paymentTypes pt,customer_payment cp
WHERE
cm.customerID=adr.customerID AND
cm.customerID=bd.customerID AND
pt.paymentID=cp.paymentID AND
cm.customerID=cp.customerID
ORDER by
bookingDate;
答案 0 :(得分:0)
你可以用简单的方法
$this->db->query("SELECT cm.customerID,cm.customerName, cm.phone,adr.address, adr.city, adr.zipcode, bd.bookingDate,bd.startBooking, bd.endBooking, pt.type FROM customers cm, addresses adr, bookings bd, paymentTypes pt,customer_payment cp WHERE cm.customerID=adr.customerID AND cm.customerID=bd.customerID AND pt.paymentID=cp.paymentID AND cm.customerID=cp.customerID ORDER by bookingDate");
答案 1 :(得分:0)
以其他方式加入查询。
$this->db->SELECT( cm.customerID,cm.customerName, cm.phone,adr.address, adr.city, dr.zipcode, bd.bookingDate,bd.startBooking, bd.endBooking, pt.type);
$this->db->FROM(customers cm);
$this->db->join(addresses adr, adr.customerID=cm.customerID);
$this->db->join(bookings bd, bd.customerID=cm.customerID );
$this->db->join(customer_payment cp, cp.customerID=cm.customerID);
$this->db->join(paymentTypes pt, pt.paymentID=cp.paymentID);
$this->db->order_by("bd.bookingDate","asc");