You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create the following MYSQL tables/views
--TABLE: commissions--
id->PRIMARY KEY
date_added
order_id->INDEX
salesrep_id->INDEX
customer_id->INDEX
commission_total
status
--VIEW: rep_view_customer--
entity_id
email
first_name
last_name
company
Create model for the table and the view.
In the Commissions model create the following relation:
'rep_view_customer' => array(self::HAS_ONE, 'RepViewCustomer', '', 'on'=>'rep_view_customer.entity_id = t.customer_id'),
In a view file(in CGridView) add the following column: 'rep_view_customer.first_name'
In RepViewCustomer set custom primary key:
public function primaryKey(){
return 'entity_id';
}
What is the expected output? What do you see instead?
You would think this would simply bring up the first name from the related row in the rep_view_customer View. It Does Not.
I get the following error:
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.customer_id' in 'where clause'. The SQL statement executed was: SELECT rep_view_customer.entity_id AS t1_c0, rep_view_customer.email AS t1_c1, rep_view_customer.first_name AS t1_c2, rep_view_customer.last_name AS t1_c3, rep_view_customer.company AS t1_c4 FROM rep_view_customerrep_view_customer WHERE (rep_view_customer.entity_id = t.customer_id)
Why would it have rep_view_customer twice in the from field?
if i do the following in my relation: 'rep_view_customer' => array(self::HAS_ONE, 'RepViewCustomer', '', 'on'=>'rep_view_customer.entity_id = 56') then i'll get a first name. but this is not correct.
What version of the product are you using? On what operating system?
Apache/2.2.21 (Fedora) Yii Framework/1.1.8
Please provide any additional information below.
I simply want to relate to another model by something other than a primary key.
What steps will reproduce the problem?
--TABLE: commissions--
id->PRIMARY KEY
date_added
order_id->INDEX
salesrep_id->INDEX
customer_id->INDEX
commission_total
status
--VIEW: rep_view_customer--
entity_id
email
first_name
last_name
company
'rep_view_customer' => array(self::HAS_ONE, 'RepViewCustomer', '', 'on'=>'rep_view_customer.entity_id = t.customer_id'),
public function primaryKey(){
return 'entity_id';
}
What is the expected output? What do you see instead?
You would think this would simply bring up the first name from the related row in the rep_view_customer View. It Does Not.
I get the following error:
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.customer_id' in 'where clause'. The SQL statement executed was: SELECT
rep_view_customer
.entity_id
ASt1_c0
,rep_view_customer
.email
ASt1_c1
,rep_view_customer
.first_name
ASt1_c2
,rep_view_customer
.last_name
ASt1_c3
,rep_view_customer
.company
ASt1_c4
FROMrep_view_customer
rep_view_customer
WHERE (rep_view_customer.entity_id = t.customer_id)Why would it have rep_view_customer twice in the from field?
if i do the following in my relation: 'rep_view_customer' => array(self::HAS_ONE, 'RepViewCustomer', '', 'on'=>'rep_view_customer.entity_id = 56') then i'll get a first name. but this is not correct.
What version of the product are you using? On what operating system?
Apache/2.2.21 (Fedora) Yii Framework/1.1.8
Please provide any additional information below.
I simply want to relate to another model by something other than a primary key.
Migrated from http://code.google.com/p/yii/issues/detail?id=3028
earlier comments
qiang.xue said, at 2012-01-01T03:37:10.000Z:
set for 1.1.10 milestone
qiang.xue said, at 2012-01-01T03:37:36.000Z:
set for 1.1.10 milestone
The text was updated successfully, but these errors were encountered: