我在controller
中使用此代码来获取连接结果,而不是包含CakePHP 3.2中的关联
$abc = $this->Products->SellerProducts->find('all', [
'conditions' => [
'Products.subcategory_id' => $id,
'SellerProducts.stock >' => 0,
],
'join' => [
'products' => [
'table' => 'Products',
'type' => 'INNER',
'conditions' => [
'products.id = SellerProducts.product_id'
]
],
'brands' => [
'table' => 'Brands',
'type' => 'INNER',
'conditions' => 'brands.id = products.brand_id'
],
'product_colors' => [
'table' => 'ProductColors',
'type' => 'INNER',
'conditions' => 'product_colors.product_id = products.id'
],
'colors' => [
'table' => 'Colors',
'type' => 'INNER',
'conditions' => 'colors.id = product_colors.color_id'
]
]
]);
但在debug
上,它只提供SellerProducts
的数据,不包括(加入)其他表。
我希望使用contain
方法得到连接结果而不是关联结果,因为contain
给出了多级数组,很难从多级数组中获取关联数据。
编辑2:调试结果($ abc);
SELECT SellerProducts.id AS `SellerProducts__id`, SellerProducts.seller_id AS `SellerProducts__seller_id`, SellerProducts.product_id AS `SellerProducts__product_id`, SellerProducts.selling_price AS `SellerProducts__selling_price` FROM seller_products SellerProducts INNER JOIN Products products ON products.id = SellerProducts.product_id INNER JOIN Brands brands ON brands.id = products.brand_id INNER JOIN ProductColors product_colors ON product_colors.product_id = products.id INNER JOIN Colors colors ON colors.id = product_colors.color_id WHERE (Products.subcategory_id = :c0 AND SellerProducts.stock > :c1)
答案 0 :(得分:0)
我想你可能会为所有领域写这样的文字:
$this->SellerProducts->find('all',['fields' => [], 'conditions' => []]
OR
$this->SellerProducts->find('all', [
'conditions' => [
'Products.subcategory_id' => $id,
'SellerProducts.stock >' => 0,
]])->join(.....);
答案 1 :(得分:0)
试试这个
Intent intent = new Intent(context, ConversationActivity.class);
intent.putExtra(ConversationUIService.TAKE_ORDER, true);//flag to disable list after back press
intent.putExtra(ConversationUIService.USER_ID, "userId");
intent.putExtra(ConversationUIService.DISPLAY_NAME, "display name");
startActivity(intent);