David Karich Posted February 27, 2014 Share Posted February 27, 2014 Is that right, i can't select the path as an OR-option in find() or get()? For example: $_pages = wire('pages')->find('id|path=1001|/about/'); produce following error: Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.path' in 'where clause' (in C:\wamp\www\Development\Processwire-Modules\PW-TESTING\wire\core\DatabaseQuery.php line 86) Same with ->get(); PHP: 5.3 and 5.5, PW version: 2.4 Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2014 Share Posted February 27, 2014 You need to install the PagePaths module which is included in the Core, but not installed by default. http://processwire.com/talk/topic/4874-what-does-page-paths-module-do/ Link to comment Share on other sites More sharing options...
David Karich Posted February 27, 2014 Author Share Posted February 27, 2014 Thank you Adrian, but I get the same error with this module. Respectively, if I adjust the selector (id|path%=1001|about): Error: Exception: Operator '%=' is not supported for 'id' Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2014 Share Posted February 27, 2014 To be honest I haven't actually used that module until now. I am also having issues with the selectors you are trying, but the following all work fine: path=/about/ id=1,path=/ path%=/about/ I think it is logical that %= wouldn't be supported for id, although I can see the issue when you're trying to combine OR's like that. Not sure if that really helps, but I am sure Ryan or someone else more familiar with that module will chime in soon. 1 Link to comment Share on other sites More sharing options...
David Karich Posted February 27, 2014 Author Share Posted February 27, 2014 With all the other selectors I have no problems. Only with this special OR selector. Link to comment Share on other sites More sharing options...
apeisa Posted February 27, 2014 Share Posted February 27, 2014 That kind of selector isn't supported yet, see roadmap for 2.5: http://processwire.com/about/roadmap/ (either-or) 1 Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2014 Share Posted February 27, 2014 I thought that too, but then I noticed that: id|name=1|about returns Home and About and: id|name=1001|about returns just About. Is it possible that Ryan has introduced partial/unannounced support already, or am I missing the point? Link to comment Share on other sites More sharing options...
teppo Posted February 27, 2014 Share Posted February 27, 2014 @adrian: http://processwire.com/talk/topic/2942-or-in-pw-selectors/?p=29001 On a mobile so I'll be very brief, but just wanted to add that the original issue is exactly what error message says: id field and %= can't be used together. You could use a combination of two finds (fetch two PageArrays and merge them) to achieve this, though someone might know better way too.. 1 Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2014 Share Posted February 27, 2014 Thanks for the link teppo, but none of the examples that David or myself have posted here are of the either/or ilk. Just to spell it out, id|name=1|about would be the same as: WHERE id=1 OR name=1 OR id=about OR name=about An either/or would maybe be: WHERE (id=1 AND name=home) OR (name=about) It's late here, so maybe I am not thinking straight, but I think I am on the right track? That said, I am not exactly sure what David is wanting to achieve with the a|b=c|d style selector. Maybe he is after an either/or, even though that's not what it currently does. I actually don't think I've seen this style documented anywhere either, but maybe it is just assumed to be obvious based on what else you can do. I might sign off now before I confuse anyone else Link to comment Share on other sites More sharing options...
apeisa Posted February 27, 2014 Share Posted February 27, 2014 You are right Adrian, I was the one confusing this Teppo is right too, error comes with using %= with id. It doesn't make any sense to use %= with id, since id%=1000 would match id:s like 910003 etc.. (if those would be strings). Link to comment Share on other sites More sharing options...
teppo Posted February 27, 2014 Share Posted February 27, 2014 @adrian, you're on the right track there, but the point is that you can't use '%=' with id's and '=' isn't always enough for text-searches, so in order to include both queries in one selector and achieve what (I believe that) David was trying to achieve you'd have to use an either-or selector (see examples below) or combine results of two separate queries. // wrong id|name%=1001|about // correct, but *not* the same thing id=1001, name%=about // correct, but requires either-or selector (id=1001)||(name%=about) // probably correct, but requires either-or selector and makes very little sense (id=1001|about)||(name%=1001|about) Forgive me for using dummy syntax for either-or, I've no idea how Ryan is going to implement this It should also be noted that id|name%=1001|about, if it worked (or that last either-or example above), would also return pages with names like "mypage1001", which probably wasn't intended. Considering that, this is definitely a job for either-or selector (first one in example above) or two combined queries. Link to comment Share on other sites More sharing options...
adrian Posted February 27, 2014 Share Posted February 27, 2014 I think it is logical that %= wouldn't be supported for id, although I can see the issue when you're trying to combine OR's like that. On a mobile so I'll be very brief, but just wanted to add that the original issue is exactly what error message says: id field and %= can't be used together. Teppo is right too, error comes with using %= with id. It doesn't make any sense to use %= with id, since id%=1000 would match id:s like 910003 etc.. (if those would be strings). @adrian, you're on the right track there, but the point is that you can't use '%=' with id's and '=' isn't always enough for text-searches, so in order to include both queries in one selector and achieve what (I believe that) David was trying to achieve you'd have to use an either-or selector (see examples below) or combine results of two separate queries. It should also be noted that id|name%=1001|about, if it worked (or that last either-or example above), would also return pages with names like "mypage1001", which probably wasn't intended. Considering that, this is definitely a job for either-or selector (first one in example above) or two combined queries. I think we were at least all on the same track regarding the issue with id and %= On the either / or issue - I really can't wait for this, it is one of the very few things in PW that are sometimes a cause of frustration because it not only feels dirty combining more than one page array, but also because of the issues regarding pagination when you do end up doing that. Nice examples there teppo Link to comment Share on other sites More sharing options...
David Karich Posted February 27, 2014 Author Share Posted February 27, 2014 Thank you guys, for all the discussion and info, that either-or is coming and currently not supported. It has me in the morning at 4:00 clock a bit confused if I was just too tired, or it really does not work. 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