似乎doctrine以错误的顺序设置参数。我有以下参数数组:
$params = array(
1 => array(1, 2, 3, 4, 5, 6),
2 => array(150, 12, 130),
3 => 'CALLED',
4 => array('ND', 'PF', 'OS'),
5 => '2015-07-02 00:00:00',
6 => '2015-07-05 00:00:00'
);
我有以下查询
$query = $this->getEntityManager()->createQuery('
SELECT c FROM Customers\Entity\Customer c
WHERE c.customer_categories_id IN(?1)
AND c.countries_id IN(?2)
AND c.state = ?3
AND c.potential_diamonds IN(?4)
AND c.last_call NOT BETWEEN ?5 AND ?6
');
$query->setParameters($params);
$result = $query->getResult();
这是最后的查询:
SELECT c0_.id AS id_0, c0_.company AS company_1, c0_.vat_number AS vat_number_2, c0_.first_name AS first_name_3, c0_.last_name AS last_name_4, c0_.phone AS phone_5, c0_.phone2 AS phone2_6, c0_.mobile AS mobile_7, c0_.email AS email_8, c0_.email2 AS email2_9, c0_.fax AS fax_10, c0_.address AS address_11, c0_.address2 AS address2_12, c0_.postal_code AS postal_code_13, c0_.town AS town_14, c0_.province AS province_15, c0_.countries_id AS countries_id_16, c0_.customer_titles_id AS customer_titles_id_17, c0_.customer_categories_id AS customer_categories_id_18, c0_.present_list AS present_list_19, c0_.vip_list AS vip_list_20, c0_.previous_sold AS previous_sold_21, c0_.previous_bought AS previous_bought_22, c0_.opening_hours AS opening_hours_23, c0_.main_office AS main_office_24, c0_.newsletter AS newsletter_25, c0_.website AS website_26, c0_.`state` AS state_27, c0_.potential_diamonds AS potential_diamonds_28, c0_.remarks AS remarks_29, c0_.date_created AS date_created_30, c0_.date_changed AS date_changed_31, c0_.last_call AS last_call_32, c0_.customer_languages_id AS customer_languages_id_33, c0_.display_state AS display_state_34, c0_.longitude AS longitude_35, c0_.latitude AS latitude_36 FROM customers c0_ WHERE c0_.customer_categories_id IN ('ND', '2015-07-05 00:00:00', 'CALLED', 130, 130, 'CALLED') AND c0_.countries_id IN ('ND', '2015-07-05 00:00:00', '2015-07-02 00:00:00') AND c0_.`state` = 'PF' AND c0_.potential_diamonds IN ('2015-07-02 00:00:00', 'OS', 'PF') AND c0_.last_call NOT BETWEEN 'OS' AND 12
如果我们查看查询的WHERE部分,我们会看到参数完全被翻转。这很奇怪。有没有人对此有解释或有相同的问题?在谷歌上找不到多少。
提前致谢