Thursday 15 May 2014

php - Closures in programmatically generated Eloquent OR queries -


I am trying to parse a query string in the supernatural, which contains the statement 'OR'. It is a very large Is the part of the function in which other filters are being used, but I want to.

My confusion comes along with the closure .. And to make sure how the correct values ​​are crossed, if I do the code below, then it says that to shut down There are incorrect arguments for this, but otherwise I can not use the $ or_list variable.

( $ item_query query is being generated during this and other actions.)

  elseif (strstr ($ column, Or | ')) {// in format or | = Tablename-id = 240, tablename -id = 8 $ or_list = explosion (',', $ value); Var_dump (Explode (',', $ value)); $ Thing_query- & gt; Where (function ($ q, $ or_list) {$ count = 0; foreach (list as $ or $} or {$ arr = explosion ('=', $ or); $ col = $ arr [0; $ Val = $ arr [1]; $ col = str_replace ('-', '.', $ Col); if ($ count == 0) {$ q-> where ($ col, '=', $ Val);} and {$ q- & gt; or_ where ($ col, '=', $ val);} $ count ++;}}); }    

Try it out: $ item_query- & Gt; Where (use the function ($ q) ($ or_list) {...



No comments:

Post a Comment