0

当我在 Magento 中使用下面的代码进行自定义查询时,它可以正常工作。

 $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $sql        = 'SELECT * FROM sales_order_custom';
    $rows       = $connection->fetchAll($sql);

但当我改变时,

$sql        = 'SELECT * FROM sales_order_custom WHERE key = "catalog_code"';

它给出了空的结果。

4

3 回答 3

0

尝试使用 $sql = SELECT * FROM sales_order_custom WHERE `key`= "catalog_code"'

于 2013-06-11T13:48:35.533 回答
0

与您类似的查询就像一个魅力......

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = "SELECT * FROM cms_page WHERE title='About  Us'";
$rows = $connection->fetchAll($sql);
var_dump($rows);
die();

无论如何,使用类似的东西会更好,但那是另一个故事:

$connection->select()->from(.....
于 2013-06-11T15:03:44.797 回答
0

查询以获取 magento 中的客户完整记录.. 姓名、地址、密码、电子邮件、联系电话

 SELECT concat((SELECT `value` FROM `customer_entity_varchar` WHERE `attribute_id`=5 AND `entity_id`= '$pup_owner'),' ', (SELECT `value` FROM `customer_entity_varchar` WHERE `attribute_id`=7 AND `entity_id`= '$pup_owner')) as `owner_name`,

 concat((SELECT `value` FROM `customer_address_entity_text` WHERE `entity_id`= (select `value` FROM `customer_entity_int` WHERE `entity_id`='$pup_owner' AND `attribute_id`=14)), ',',(SELECT `value` FROM `customer_address_entity_varchar` WHERE `attribute_id`=26 AND `entity_id`= (select `value` FROM `customer_entity_int` WHERE `entity_id`='$pup_owner' AND `attribute_id`=14)),',' ,(SELECT `value` FROM `customer_address_entity_varchar` WHERE `attribute_id`=28 AND `entity_id`= (select `value` FROM `customer_entity_int` WHERE `entity_id`='$pup_owner' AND `attribute_id`=14))) as `owner_address`,

 concat((SELECT `value` FROM `customer_address_entity_varchar` WHERE `attribute_id`=30 AND `entity_id`= (select `value` FROM `customer_entity_int` WHERE `entity_id`='$pup_owner' AND `attribute_id`=14)),'') as `owner_pincode` ,

 concat((SELECT `email` FROM `customer_entity` WHERE `entity_id`= '$pup_owner'),'') as `owner_email` ,

 concat((SELECT `value` FROM `customer_address_entity_varchar` WHERE `attribute_id`=31 AND `entity_id`= (select `value` FROM `customer_entity_int` WHERE `entity_id`='$pup_owner' AND `attribute_id`=14)),'') as `owner_contact`
于 2014-01-11T19:56:48.967 回答