Symfony 1/Doctrine:0 个结果在应用程序中,35 个结果在 mysql 具有相同查询的客户端中

Symfony 1/Doctrine : 0 result in application and 35 results in mysql client with the same query

我遇到了 Doctrine 查询的问题,当我的应用程序执行查询时它找不到任何结果。

symfony 日志:

../..
Aug 07 11:31:38 symfony [info] {Doctrine_Connection_Statement} execute : SELECT i.id AS i__id, i.reference AS i__reference, i.art_code AS i__art_code, i.commentaire AS i__commentaire, i.image AS i__image, i.marque_id AS i__marque_id, i.article_type_id AS i__article_type_id, i.reference_fournisseur AS i__reference_fournisseur, i.historique AS i__historique, i.article_id AS i__article_id, i.reference_client AS i__reference_client, i.domaine_id AS i__domaine_id, i.migration_id AS i__migration_id, i.date_validite AS i__date_validite, i.list_pays AS i__list_pays, i.type AS i__type, i.created_at AS i__created_at, i.updated_at AS i__updated_at, f.id AS f__id, f.reference AS f__reference, f.nom AS f__nom, f.lang AS f__lang, f.article_id AS f__article_id, i2.id AS i2__id, i2.nom AS i2__nom, i2.lang AS i2__lang, f2.id AS f2__id, f2.reference AS f2__reference, f2.nom AS f2__nom, f2.lang AS f2__lang, f2.produit_id AS f2__produit_id, f2.domaine_id AS f2__domaine_id, f2.marque_id AS f2__marque_id FROM item i INNER JOIN flat_search_article f ON i.id = f.article_id INNER JOIN item_translation i2 ON i.id = i2.id INNER JOIN flat_search_article_produit f3 ON (f.id = f3.article_id) INNER JOIN flat_search_produit f2 ON f2.id = f3.produit_id WHERE (i2.lang = :lang AND f.lang = :lang AND (f.reference LIKE "%:kwa%" OR f.nom LIKE "%:kwa%") AND f2.lang = :lang AND (f2.reference LIKE "%:kwp%" OR f2.nom LIKE "%:kwp%") AND (i.type = 1)) - (fr, ALLUM, IDRA)
../..

mysql 控制台客户端中具有相同参数的完全相同的查询:

mysql> SELECT i.id AS i__id, i.reference AS i__reference, i.art_code AS i__art_code, i.commentaire AS i__commentaire, i.image AS i__image, i.marque_id AS i__marque_id, i.article_type_id AS i__article_type_id, i.reference_fournisseur AS i__reference_fournisseur, i.historique AS i__historique, i.article_id AS i__article_id, i.reference_client AS i__reference_client, i.domaine_id AS i__domaine_id, i.migration_id AS i__migration_id, i.date_validite AS i__date_validite, i.list_pays AS i__list_pays, i.type AS i__type, i.created_at AS i__created_at, i.updated_at AS i__updated_at, f.id AS f__id, f.reference AS f__reference, f.nom AS f__nom, f.lang AS f__lang, f.article_id AS f__article_id, i2.id AS i2__id, i2.nom AS i2__nom, i2.lang AS i2__lang, f2.id AS f2__id, f2.reference AS f2__reference, f2.nom AS f2__nom, f2.lang AS f2__lang, f2.produit_id AS f2__produit_id, f2.domaine_id AS f2__domaine_id, f2.marque_id AS f2__marque_id FROM item i INNER JOIN flat_search_article f ON i.id = f.article_id INNER JOIN item_translation i2 ON i.id = i2.id INNER JOIN flat_search_article_produit f3 ON (f.id = f3.article_id) INNER JOIN flat_search_produit f2 ON f2.id = f3.produit_id WHERE (i2.lang = 'fr' AND f.lang = 'fr' AND (f.reference LIKE "%ALLUM%" OR f.nom LIKE "%ALLUM%") AND f2.lang = 'fr' AND (f2.reference LIKE "%IDRA%" OR f2.nom LIKE "%IDRA%") AND (i.type = 1));
+--------+--------------+-------------+----------------+----------------------------------------------+--------------+--------------------+--------------------------+---------------+---------------+---------------------+---------------+-----------------+------------------+--------------+---------+---------------------+---------------------+-------+--------------+-----------------------------+---------+---------------+--------+-----------------------------+----------+--------+---------------+--------------------------------------+----------+----------------+----------------+---------------+
| i__id  | i__reference | i__art_code | i__commentaire | i__image                                     | i__marque_id | i__article_type_id | i__reference_fournisseur | i__historique | i__article_id | i__reference_client | i__domaine_id | i__migration_id | i__date_validite | i__list_pays | i__type | i__created_at       | i__updated_at       | f__id | f__reference | f__nom                      | f__lang | f__article_id | i2__id | i2__nom                     | i2__lang | f2__id | f2__reference | f2__nom                              | f2__lang | f2__produit_id | f2__domaine_id | f2__marque_id |
+--------+--------------+-------------+----------------+----------------------------------------------+--------------+--------------------+--------------------------+---------------+---------------+---------------------+---------------+-----------------+------------------+--------------+---------+---------------------+---------------------+-------+--------------+-----------------------------+---------+---------------+--------+-----------------------------+----------+--------+---------------+--------------------------------------+----------+----------------+----------------+---------------+
|     12 | 100261       | 100261      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          540984 | NULL             | NULL         | 1       | 2010-03-04 18:35:04 | 2010-03-17 18:28:57 |    18 | 100261       | ALLUM PIEZO IDRA23S         | fr      |            12 |     12 | ALLUM PIEZO IDRA23S         | fr       |   8328 | 7522395Z      | IDRA 23 B                            | fr       |          80860 |              6 |             5 |
|     12 | 100261       | 100261      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          540984 | NULL             | NULL         | 1       | 2010-03-04 18:35:04 | 2010-03-17 18:28:57 |    18 | 100261       | ALLUM PIEZO IDRA23S         | fr      |            12 |     12 | ALLUM PIEZO IDRA23S         | fr       |   8327 | 7522395P      | IDRA 23 BP                           | fr       |          80859 |              6 |             5 |
|     15 | 100264       | 100264      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          540987 | NULL             | NULL         | 1       | 2010-03-04 18:35:04 | 2010-03-17 18:28:58 |    24 | 100264       | ALLUM ELECT IDRA24S         | fr      |            15 |     15 | ALLUM ELECT IDRA24S         | fr       |   8335 | 7522499       | IDRA EXCLUSIVE 24 S Ref:7522488Z     | fr       |          80867 |              6 |             5 |
|     15 | 100264       | 100264      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          540987 | NULL             | NULL         | 1       | 2010-03-04 18:35:04 | 2010-03-17 18:28:58 |    24 | 100264       | ALLUM ELECT IDRA24S         | fr      |            15 |     15 | ALLUM ELECT IDRA24S         | fr       |   8337 | 7512499       | IDRA 24                              | fr       |          80869 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8300 | 7522477P      | IDRA Exclusive 24 BVIP               | fr       |          80832 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8301 | 7522477Z      | IDRA Exclusive 24 BVI                | fr       |          80833 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8306 | 7522483P      | IDRA Exclusive 24 BIPD               | fr       |          80838 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8307 | 7522483Z      | IDRA Exclusive 24 BID                | fr       |          80839 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |  15540 | 021494        | IDRA EXCLUSIVE 24 BID Ref:7522483Z   | fr       |         149781 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |  15541 | 021495        | IDRA E24BIPD Ref:7522483P            | fr       |         149782 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8308 | 7522484Z      | IDRA Exclusive 24 BI VMC             | fr       |          80840 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8311 | 7522487Z      | IDRA Exclusive 24 BI                 | fr       |          80843 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8316 | 021496        | IDRA EXCLUSIVE 28 BVIPD Ref:7522876P | fr       |          80848 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8317 | 021493        | IDRA EXCLUSIVE 28 BVID Ref:7522876Z  | fr       |          80849 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8318 | 7522877P      | IDRA Exclusive 28 BVIP               | fr       |          80850 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |   8319 | 7522877Z      | IDRA Exclusive 28 BVI                | fr       |          80851 |              6 |             5 |
|     89 | 102112       | 102112      |                | be6f4bf56796ec7d2b6527a42f6098d2d99579ae.jpg |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541063 | NULL             | NULL         | 1       | 2010-03-04 18:35:07 | 2010-07-01 12:36:14 |   136 | 102112       | BOIT ALLUM IDRAE24BI        | fr      |            89 |     89 | BOIT ALLUM IDRAE24BI        | fr       |  15539 | 021492        | IDRA EXCLUSIVE 24 BIVMC Ref:7522484Z | fr       |         149780 |              6 |             5 |
|    221 | 109176       | 109176      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541195 | NULL             | NULL         | 1       | 2010-03-04 18:35:13 | 2010-03-17 18:31:10 |   360 | 109176       | CABLE ALLUM IDRA23B         | fr      |           221 |    221 | CABLE ALLUM IDRA23B         | fr       |   8328 | 7522395Z      | IDRA 23 B                            | fr       |          80860 |              6 |             5 |
|    221 | 109176       | 109176      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541195 | NULL             | NULL         | 1       | 2010-03-04 18:35:13 | 2010-03-17 18:31:10 |   360 | 109176       | CABLE ALLUM IDRA23B         | fr      |           221 |    221 | CABLE ALLUM IDRA23B         | fr       |   8327 | 7522395P      | IDRA 23 BP                           | fr       |          80859 |              6 |             5 |
|    222 | 109177       | 109177      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541196 | NULL             | NULL         | 1       | 2010-03-04 18:35:13 | 2010-03-17 18:31:11 |   362 | 109177       | CABLE ALLUM IDRA24S         | fr      |           222 |    222 | CABLE ALLUM IDRA24S         | fr       |   8335 | 7522499       | IDRA EXCLUSIVE 24 S Ref:7522488Z     | fr       |          80867 |              6 |             5 |
|    222 | 109177       | 109177      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          541196 | NULL             | NULL         | 1       | 2010-03-04 18:35:13 | 2010-03-17 18:31:11 |   362 | 109177       | CABLE ALLUM IDRA24S         | fr      |           222 |    222 | CABLE ALLUM IDRA24S         | fr       |   8337 | 7512499       | IDRA 24                              | fr       |          80869 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |   8419 | 021784        | IDRAECO CONDENS MICRO 4120/28 V R    | fr       |          80945 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |   8418 | 021782        | IDRA CONDENS MICRO 4124/32 V R       | fr       |          80944 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |   8412 | 021705        | IDRA4030MBV7523099Z                  | fr       |          80938 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |   8417 | 021752        | IDRA CONDENS ECO 4020 SV R           | fr       |          80943 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |  15557 | 021783        | IDRA CONDENS DUO 4124/32 V R         | fr       |         149796 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |  76842 | 021785        | IDRA ECO CONDENS DUO 5024/32 V R     | fr       |         231030 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |  84351 | 021795        | IDRAECO CONDENS 5012                 | fr       |         241623 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |  88266 | 021798        | IDRAECO CONDENS 5012 +               | fr       |         251993 |              6 |             5 |
|  11892 | 198638       | 198638      |                | NULL                                         |         NULL |               NULL |                          |               |          NULL | NULL                |          NULL |          553720 | NULL             | NULL         | 1       | 2010-03-04 18:43:22 | 2010-03-17 19:15:43 | 14783 | 198638       | TRANSFO D ALLUMAGE          | fr      |         11892 |  11892 | TRANSFO D ALLUMAGE          | fr       |  88314 | 021808        | IDRAECO CONDENS DUO 5024/35 60L      | fr       |         252077 |              6 |             5 |
|  45822 | 109589       | 109589      |                | NULL                                         |         NULL |               NULL |                          | NULL          |          NULL | NULL                |          NULL |          618340 | NULL             | NULL         | 1       | 2010-03-04 19:04:33 | 2010-03-17 18:31:45 | 30400 | 109589       | CABLE TRANSFO ALLUMAGE      | fr      |         45822 |  45822 | CABLE TRANSFO ALLUMAGE      | fr       |   8419 | 021784        | IDRAECO CONDENS MICRO 4120/28 V R    | fr       |          80945 |              6 |             5 |
| 244393 | 124491       | 124491      | NULL           | NULL                                         |         NULL |               NULL |                          | NULL          |          NULL | NULL                |          NULL |            NULL | NULL             | NULL         | 1       | 2013-08-30 05:01:43 | 2013-08-30 05:01:43 | 84170 | 124491       | ELECTROE ALLUMAGE           | fr      |        244393 | 244393 | ELECTROE ALLUMAGE           | fr       |  84351 | 021795        | IDRAECO CONDENS 5012                 | fr       |         241623 |              6 |             5 |
| 244393 | 124491       | 124491      | NULL           | NULL                                         |         NULL |               NULL |                          | NULL          |          NULL | NULL                |          NULL |            NULL | NULL             | NULL         | 1       | 2013-08-30 05:01:43 | 2013-08-30 05:01:43 | 84170 | 124491       | ELECTROE ALLUMAGE           | fr      |        244393 | 244393 | ELECTROE ALLUMAGE           | fr       |  88266 | 021798        | IDRAECO CONDENS 5012 +               | fr       |         251993 |              6 |             5 |
| 244396 | 115112       | 115112      | NULL           | NULL                                         |         NULL |               NULL |                          | NULL          |          NULL | NULL                |          NULL |            NULL | NULL             | NULL         | 1       | 2013-08-30 05:01:43 | 2013-08-30 05:01:43 | 84173 | 115112       | CABLAGE ELECTRIQUE ALLUMAGE | fr      |        244396 | 244396 | CABLAGE ELECTRIQUE ALLUMAGE | fr       |  84351 | 021795        | IDRAECO CONDENS 5012                 | fr       |         241623 |              6 |             5 |
| 244396 | 115112       | 115112      | NULL           | NULL                                         |         NULL |               NULL |                          | NULL          |          NULL | NULL                |          NULL |            NULL | NULL             | NULL         | 1       | 2013-08-30 05:01:43 | 2013-08-30 05:01:43 | 84173 | 115112       | CABLAGE ELECTRIQUE ALLUMAGE | fr      |        244396 | 244396 | CABLAGE ELECTRIQUE ALLUMAGE | fr       |  88266 | 021798        | IDRAECO CONDENS 5012 +               | fr       |         251993 |              6 |             5 |
+--------+--------------+-------------+----------------+----------------------------------------------+--------------+--------------------+--------------------------+---------------+---------------+---------------------+---------------+-----------------+------------------+--------------+---------+---------------------+---------------------+-------+--------------+-----------------------------+---------+---------------+--------+-----------------------------+----------+--------+---------------+--------------------------------------+----------+----------------+----------------+---------------+
35 rows in set (0.00 sec)

这是查询构造的源代码:

public function search ($keywords_article, $lang, $keywords_produit = '', $limit = 0, $offset = 0)
{
    $q = $this->createQuery('a')
        ->innerJoin('a.FlatSearchArticles fa')
        ->innerJoin('a.Translation t')
        ->where('t.lang = :lang')
        ->addWhere('fa.lang = :lang')
        ->addWhere('fa.reference LIKE "%:kwa%" OR fa.nom LIKE "%:kwa%"');

    if ('' != $keywords_produit)
        $q->innerJoin('fa.FlatSearchProduits fp')
            ->addWhere('fp.lang = :lang')
            ->addWhere('fp.reference LIKE "%:kwp%" OR fp.nom LIKE "%:kwp%"');

    if (0 != $limit)
        $q->limit($limit);

    if (0 != $offset)
        $q->offset($offset);

    return $q->execute(array(
        ':lang' => $lang,
        ':kwa' => $keywords_article,
        ':kwp' => $keywords_produit,
    ));
}

怎么可能?我快疯了。

感谢您的支持, 大卫.

解决方案是我不能在准备查询中使用“%”和“"”。

这是正确的函数:

public function search ($keywords_article, $lang, $keywords_produit = '', $limit = 0, $offset = 0)
{
    $q = $this->createQuery('a')
        ->innerJoin('a.FlatSearchArticles fa')
        ->innerJoin('a.Translation t')
        ->where('t.lang = :lang')
        ->addWhere('fa.lang = :lang')
        ->addWhere('fa.reference LIKE :kwa OR fa.nom LIKE :kwa');

    if ('' != $keywords_produit)
        $q->innerJoin('fa.FlatSearchProduits fp')
            ->addWhere('fp.lang = :lang')
            ->addWhere('fp.reference LIKE :kwp OR fp.nom LIKE :kwp');

    if (0 != $limit)
        $q->limit($limit);

    if (0 != $offset)
        $q->offset($offset);

    return $q->execute(array(
        ':lang' => $lang,
        ':kwa' => '%' . $keywords_article . '%',
        ':kwp' => '%' . $keywords_produit . '%'
    ));
}

不,我还有其他问题,我会 post 在新主题中解决这个问题。

感谢朋友给我解答, 大卫.