Saturday 15 January 2011

php - Issue with createQueryBuilder and MongoRegex -


After doing many research for the creator for Mangode, I can not solve my problem. Can you help me Here is the structure of the data:

  one field 1 field: {???? Field 2a ???? Value 1a a, ???? Field 3 ??? : {a ??? Field 4a ??? : One ???? Value 2a, ????, field 5: one ???? Value3aâ ????}} One field 1 field: {Â} field 2: ???? Line Value1b ??? Line, field 3 : {a ??? Field 4a ??? : One ???? Value 2b, ????, field 5: one ???? Value3bâ ????}} One field 1 field: {Â ??? Field 2a ?????: A ???? Value 1cA, ???? Field 3 ??? : {a ??? Field 4a ??? : One ???? Value 2c, ???? Field 5: One ???? Value3câ ????}}   

How can I get the whole line where Field5 = value3a? I have proceeded with the code given below but it does not give me a record:

  $ keywords = "test"; $ Keyword_are = explosion (',', $ keyword); $ NbKeyword = Count ($ keyword_ray); $ Odm = $ this- & gt; Get ("theory mongodb"); $ Donnees = $ odm- & gt; CreateQueryBuilder ("MyBundle: MyCollection"); ($ I = 0; $ i & lt; $ nb keyword; $ i ++) {$ search = new \ MongoRegex ('/ "field5": "'. $ Keywords_Array [$ i]. '" /') ; $ Donnees = $ donnees-> Field ("field 1") - & gt; Equal (new \ MongoRegex ('/' Field3 ":" '. $ Search.' '/'));} $ Donnees = $ donnees-> getQuery () -> execute (); Foreach ($ $ Donnees in the form of data) {$ resp = $ data-> GetResult ();} Return $ Resp   

and another structure of data (here, one of the data values Array is):

  one field1 field: {Â · field 2a ????: [â ???? value1 'a, ???? value2â ?? ??, '???? value3â ????]}   

How can I get the whole line where Field2 = value3? It is similar to the above code given below, It does not give me any records:

  $ keywords = "test"; $ keyword_are = explosion (',', $ keyword); $ nbKeyword = count ($ keyword_are); $ odm = $ this- & gt; ("theory mongodb") ; $ Donnees = $ odm- & gt; createQueryBuilder ("mybundle: MyCollection"); ($ i = 0; $ i & lt; $ nb keyword; $ i ++) {$ donnees = $ donnees-> ; Field ("field 1") - & gt; equal (new \ MongoRegex ('/ "Field2": "'. $ Keywords_Array [$ i]. '" / I')); } $ Donnees = $ donnees-> GetQuery () - & gt; carry about (); Foreach ($ donnees as $ data) {$ resp = $ data-> GetResult (); } Return $ $;   

Thanks in advance

The problem is fixed. I have the same problem in case of any post solution. For the first structure of data, the code should be:

  $ keywords = "test"; $ Keyword_are = explosion (',', $ keyword); $ NbKeyword = Count ($ keyword_ray); $ Odm = $ this- & gt; Get ("theory mongodb"); $ Donnees = $ odm- & gt; CreateQueryBuilder ("MyBundle: MyCollection"); ($ I = $; $ i & lt; $ nb keyword; $ i ++) {$ donnees = $ donnees-> Field ('Field 1') - & gt; Equal (new \ MongoRegex ('/ "Field5":'. $ Keywords_Array [$ i] '/')). } $ Donnees = $ donnees-> GetQuery () - & gt; carry about (); Foreach ($ donnees as $ data) {$ resp = $ data-> GetResult (); } Return $ $;   

And for the second structure of the data, the code should be:

  $ keywords = "test"; $ Keyword_are = explosion (',', $ keyword); $ NbKeyword = Count ($ keyword_ray); $ Odm = $ this- & gt; Get ("theory mongodb"); $ Donnees = $ odm- & gt; CreateQueryBuilder ("MyBundle: MyCollection"); $ $ ($ I = 0; $ i & lt; $ nb keyword; $ i ++) {$ keys = new \ MongoRegex ("/A: Keywords_Array [$ i]." / "); $ Donnees = $ Donnees-> Fields ("Field 1") -> (Array ("Field2" => = Keys));} $ Donnees = $ donnees- & gt; getQuery () - & ;; Execute (); Foreach ($ donnees as $ data) {$ resp = $ data-> GetResult ();} Return $ Response;   

Thanks. < / P>

No comments:

Post a Comment