我有两个查询,一个接收电子邮件和密码,另一个接受客户端的名称,是否有人知道或加入或任何获取此数据的查询?
// get client email and password
SELECT c.entity_id,c.email,
(
SELECT fn.value
FROM customer_entity_varchar fn
WHERE c.entity_id = fn.entity_id AND
fn.attribute_id = 12) AS password_hash,
(
SELECT fn.value
FROM customer_address_entity_varchar fn
WHERE ca.entity_id = fn.entity_id AND
fn.attribute_id = 30) AS cep
FROM customer_entity AS c
LEFT JOIN customer_address_entity AS ca ON c.entity_id = ca.parent_id
LEFT JOIN customer_address_entity_text AS cat ON cat.entity_id = ca.entity_id
GROUP BY entity_id
// get name from client
SELECT entity_id, group_concat(VALUE SEPARATOR ' ') AS fullname FROM customer_entity_varchar AS fn INNER JOIN eav_attribute AS attr ON attr.attribute_id = fn.attribute_id WHERE attr.attribute_code IN ( 'firstname', 'lastname' ) GROUP BY entity_id;
答案 0 :(得分:0)
当你可以使用Magento的ORM时,不需要使用sql。我假设你想做某种客户出口。
创建一个回显数据并将其保存到文件的shell脚本:
php shell/customer-export.php > customers.csv
在您的shell/customer-export.php
中,您可以使用客户集合(Mage::getResourceModel('customer/customer_collection')
)来实现此目标。