$paginationQuery
->select([
'EventTicketSalesDelegates.attending',
'EventTicketSalesDelegates.event_package_id',
'EventPackages.name', 'EventPackages.id',
'EventPackages.description',
'Contacts.id', 'Contacts.name', 'Contacts.email',
'Contacts.mobile', 'Contacts.company',
'Contacts.phone', 'Contacts.fax', 'Contacts.address_one',
'Contacts.address_two', 'Contacts.comments', 'Contacts.job_title',
])
->join(
[
'EventTicketSalesDelegates' => [
'table' => 'event_ticket_sales_delegates',
'type' => 'INNER',
'conditions' => [
'EventTicketSalesDelegates.contact_id = Contacts.id'
]
],
'EventTicketSales' => [
'table' => 'event_ticket_sales',
'type' => 'INNER',
'conditions' => [
'EventTicketSalesDelegates.event_ticket_sale_id = EventTicketSales.id'
]
],
'EventPackages' => [
'table' => 'event_packages',
'type' => 'INNER',
'conditions' => [
'EventPackages.id = EventTicketSalesDelegates.event_package_id'
]
]
]
)->where(['EventTicketSales.id' => $eventTicketSaleId]);
name: "Song 123",
email: "abc@abc.com",
mobile: "+62 123",
company: "SK ",
phone: "+62 123",
fax: "",
address_one: "",
address_two: "",
comments: "",
job_title: "Director",
EventTicketSalesDelegates: {
attending: "1",
event_package_id: "53"
}
,
EventPackages: {
name: "Roundtable Forum Only",
id: "53",
description: "Roundtable Forum Only(3 Mar 2016 9:00 - 4 Mar 2016 12:00)"
},
attending: "1",
event_package_id: "53"
我希望event_package_id为整数
我在查询后添加了这个。
$paginationQuery
->selectTypeMap()
->addDefaults([
'EventTicketSalesDelegates.event_package_id' => 'integer',
]);
Undefined index: EventTicketSalesDelegates.event_package_id
答案 0 :(得分:0)
除非您在select()
调用中定义自定义别名,否则在添加类型时必须使用CakePHP默认别名格式,即
AssociationName__column_name
所以在你的情况下EventTicketSalesDelegates__event_package_id
。
您还可以通过Query::aliasField()
以编程方式检索别名,例如
key($paginationQuery->aliasField('event_package_id', 'EventTicketSalesDelegates'))