Magento过滤器的相对值 [英] Magento Filter By Relative Value

查看:52
本文介绍了Magento过滤器的相对值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按该行的相对值过滤一个集合.例如,

I would like to filter a collection by relative value per that row. For example,

SELECT * FROM table WHERE column_1 > column_2

我唯一会在Magento中做的事就是

The only thing I know how to do in Magento would be

$q = Mage::getModel('table')->getCollection()
         ->addAttributeToFilter('column_1', array('gt' => $some_number));

或类似的东西.我只能给它一个要比较的值,而不是列名.我还查看了 where 子句中的 Zend_Db_Select 方法,但没有找到任何有帮助的方法.实际上,我是否必须一直进行直接的SQL查询(当然会不惜一切代价避免这种情况)?(我正在运行Magento 1.3.2.4)

or something of that sort. I can only give it a value to compare against, not a column name. I also looked at the Zend_Db_Select method at the where clause but didn't find anything that would help. Do I actually have to go all the way down to a direct SQL query (something which is, of course, avoided at all costs)? (I'm running Magento 1.3.2.4)

谢谢.

推荐答案

尝试类似

$q = Mage::getModel('table')->getCollection()
    ->addAttributeToSelect('column_1')
    ->addAttributeToSelect('column_2')
    ->addAttributeToFilter('column_1', array('gt' => Zend_Db_Expr('`column_2`')));

这篇关于Magento过滤器的相对值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆