Magento 2: What's best way to convert MySql to Magento
-
12-01-2021 - |
سؤال
I've below MySql query, I would like to change use it in Magento format.
How can i do that ?
SELECT customer_entity_varchar.value, customer_entity_text.value from customer_entity INNER JOIN customer_entity_varchar ON customer_entity.entity_id=customer_entity_varchar.entity_id INNER JOIN customer_entity_text ON customer_entity.entity_id = customer_entity_text.entity_id
I've tried below but it only returns me. One table values not other ones.
$connection = $this->_resource->getConnection();
$select = $connection->select()
->from(
['customer_entity']
)
->join('customer_entity_varchar', 'customer_entity.entity_id = customer_entity_varchar.entity_id')
->join('customer_entity_text', 'customer_entity.entity_id = customer_entity_text.entity_id');
$selectnew = $connection->fetchAssoc($select);
echo "<pre>";
print_r($selectnew); exit;
Any help would be really appreciated.
المحلول
Try this:
$items->getSelect()
->join(
array('l' => 'customer_entity_varchar'),
'l.entity_id = l.entity_id',
array('profile' => 'l.value')
)
->join(
array('m' => 'customer_entity_text'),
'm.entity_id = l.entity_id',
array('status' => 'm.value')
);
لا تنتمي إلى magento.stackexchange