Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento连接表_Php_Magento_Join - Fatal编程技术网

Php Magento连接表

Php Magento连接表,php,magento,join,Php,Magento,Join,我需要在我的查询中加入costum表。 我需要按“实体id”类别对所有订购的产品进行循环,如果有效,则加入此选择 SELECT *, pps_product_id, MIN(pps_last_unit_price) AS pps_last_unit_price, pps_quantity_product FROM ".Mage::getSingleton('core/resource')->getTableName('purchase_produ

我需要在我的查询中加入costum表。 我需要按“实体id”类别对所有订购的产品进行循环,如果有效,则加入此选择

SELECT *,
    pps_product_id, 
    MIN(pps_last_unit_price) AS pps_last_unit_price, 
    pps_quantity_product
    FROM
    ".Mage::getSingleton('core/resource')->getTableName('purchase_product_supplier')."
    WHERE
    pps_last_unit_price > '0'
    AND pps_last_unit_price != '' AND pps_product_id = ".$data['entity_id']."
    GROUP BY
    pps_product_id
并与
SELECT*连接,将(实体id)计数为conta FROM
.Mage::getSingleton('core/resource')->getTableName('catalog\u category\u entity\u varchar')
其中属性_id=192,实体_id=“.IDProduto.”和值!=“”和价值0'
如果是有效的。 有人能帮我吗?
感谢

首先,通常情况下,在Magento中最好使用Magento模型来查询数据库。这样,如果您决定切换,您的查询也将在其他数据库上工作(据我所知,目前不受支持,但仍然值得)

我喜欢使用or来计算连接

你的问题很模糊。能否提供自定义表的架构?什么与什么结合在一起?在什么领域

首先,我会说它看起来像这样:

$pps = Mage::getModel('purchase_product_supplier')->getCollection()
    ->addAttributeToFilter('pps_last_unit_price', array('gt' => 0))
    ->addAttributeToFilter('pps_last_unit_price', true)
    ->addAttributeToFilter('pps_product_id',      $data['entity_id']);

$pps->getSelect()->join(


);

首先,在Magento中,通常最好使用Magento模型来查询数据库。这样,如果您决定切换,您的查询也将在其他数据库上工作(据我所知,目前不受支持,但仍然值得)

我喜欢使用or来计算连接

你的问题很模糊。能否提供自定义表的架构?什么与什么结合在一起?在什么领域

首先,我会说它看起来像这样:

$pps = Mage::getModel('purchase_product_supplier')->getCollection()
    ->addAttributeToFilter('pps_last_unit_price', array('gt' => 0))
    ->addAttributeToFilter('pps_last_unit_price', true)
    ->addAttributeToFilter('pps_product_id',      $data['entity_id']);

$pps->getSelect()->join(


);
为什么不:

$orders->getSelect()->join(
    array('p' => $orders->getResource()->getTable('sales/order_payment')),
        'p.parent_id = main_table.entity_id',
        array('cc_last4' => 'p.cc_last4',
           'cc_type'  => 'p.cc_type',
           'additional_information'  => 'p.additional_information',
        )
     );
为什么不:

$orders->getSelect()->join(
    array('p' => $orders->getResource()->getTable('sales/order_payment')),
        'p.parent_id = main_table.entity_id',
        array('cc_last4' => 'p.cc_last4',
           'cc_type'  => 'p.cc_type',
           'additional_information'  => 'p.additional_information',
        )
     );