theoretic Posted October 29, 2018 Share Posted October 29, 2018 Hi there! And thanks for Processwire! It appears that i've found something interesting about PW selectors. They should only be strings! Here's an example of SQL-like syntax for selector: $my_complex_selector = " name='some name', parameter=123, other_parameter=[subparam>=subvalue] "; Trying to use this selector lead to a very buggy PW behaviour. It appears that newlines are treated in a very special manner by PW selector engine, preventing the newlined selectors from working as expected. I cannot imagine a situation when an unescaped newline could be a part of selector or selector value, so stripping newline symbols from selector could be a good idea for further PW development. And, currently, another good idea is to write complex selectors as PHP arrays: $my_complex_selector = [ "name=$name", "param1=$param1", ]; and to implode them into a single line before using find() and other functions which use selectors. Sorry if i wrote something trivial, but having this post already present at support forum could save me a couple of hours. Hope mine will save that tame for someone else ? Link to comment Share on other sites More sharing options...
Zeka Posted October 29, 2018 Share Posted October 29, 2018 @theoretic Actualy there are two options for writing selectors as associative arrays and reqular arrays. https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#selector-engine-array-support 4 Link to comment Share on other sites More sharing options...
theoretic Posted October 29, 2018 Author Share Posted October 29, 2018 @Zeka, thanks! The built-in selector array representation is good for relatively simple queries. But i couldn't find any example of correct select array syntax for cases like my_repeater = [ my_repeater_field1=value1, my_repeater_field2>value2, my_repeater_field3%=value3 ] I suppose that there's some array syntax for cases like this but i could'n find it. Link to comment Share on other sites More sharing options...
adrian Posted October 29, 2018 Share Posted October 29, 2018 8 minutes ago, theoretic said: @Zeka, thanks! The built-in selector array representation is good for relatively simple queries. But i couldn't find any example of correct select array syntax for cases like my_repeater = [ my_repeater_field1=value1, my_repeater_field2>value2, my_repeater_field3%=value3 ] I suppose that there's some array syntax for cases like this but i could'n find it. You might find what you need in this post: https://processwire.com/talk/topic/19024-selector-arrays-with-page-reference-fields-with-and-not-or/ 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now