Yii Framework Forum: Problema Con Distinct + Relazione 1 A N Tra Tabelle - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problema Con Distinct + Relazione 1 A N Tra Tabelle Rate Topic: -----

#1 User is offline   realtebo 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 621
  • Joined: 03-October 12
  • Location:Ferrara

Posted 03 January 2013 - 06:10 AM

Ho la tabella Queue che contiene il campo delivery_id, il quale punta a Delivery.id

In Queue ho questa relation
'delivery' => array(self::BELONGS_TO, 'Delivery', 'delivery_id'),


La tabella Delivery contiene il campo client_id (perchè un cliente può avere N delivery)

Sto cercando di ottenere questo

"SELECT DISTINCT(queue.delivery.id), delivery.client_id FROM ... <join vari>"

Come posso farlo con gli strumenti di Yii?

Ho provato questo, ma non funziona
        $queued_delivery =Queue::model()->findAll(array(
                                                    'select'=>'t.delivery_id, delivery.client_id',
                                                    'with' => 'delivery',
                                                    'distinct'=>true,
                                                  )
                                                );   


Mi dice

Quote

Active record "Queue" is trying to select an invalid column "delivery.client_id". Note, the column must exist in the table or be an expression with alias

Il computer non ragiona, ma ha sempre ragione.
Ricordalo quando fai il debug
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users