我在Magento有以下收藏: -
$this->addFieldToFilter(array('postcode', 'organisation_name'),array(
array('eq' => $postcode),
array('like' => $lastname. '%')
));
return $this;
这将返回一个查询,如下所示:
SELECT `main_table`.`organisation_id`, `main_table`.`organisation_id`,
`main_table`.`organisation_type_id`, `main_table`.`organisation_name`, `main_table`.`street`,
`main_table`.`town`, `main_table`.`county`, `main_table`.`country`, `main_table`.`postcode` FROM
`organisation` AS `main_table` WHERE ((postcode = 'AA11AA')
OR (organisation_name LIKE 'jones%'))
LIMIT 1
如何修改它,使其在返回的SQL查询中成为AND而不是OR?
答案 0 :(得分:2)
试试这样:
$this->addFieldToFilter('postcode',array('eq' => $postcode))
->addFieldToFilter('organisation_name',array('like' => $lastname. '%'))