Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Aktiver Datensatz in Coigniter

Probieren Sie es einfach aus und lassen Sie es mich wissen,

$this->db->select("b.name,SUM(CASE WHEN c.size = 'S' THEN 1 ELSE 0 END) S,SUM(CASE WHEN c.size = 'M' THEN 1 ELSE 0 END) M,SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) L,SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) XL", FALSE );
$this->db->from('orderTB a');
$this->db->join('productTB b','a.id_product = b.id_shirt','inner');
$this->db->join('sizeTB c','a.id_size = c.id_size','inner');
$this->db->group_by('b.name');

Aus dem Dokument hier

BEARBEITEN

Fügen Sie einfach FALSE hinzu in Ihrer Select-Anweisung

function get() {
    $this->db->select("b.name,SUM(CASE WHEN c.size ='S' THEN 1 ELSE 0 END) as S,SUM(CASE    WHEN c.size = 'M' THEN 1 ELSE 0 END) as M,SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) as   L,SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) as XL",FALSE);

    $this->db->from('order');
    $this->db->join('ukuran','order.id_size=ukuran.id_size');
    $this->db->where('date',$date);
    return $this->db->get();
}