• Resolved steevithak

    (@steevithak)


    I’m trying to use the find() function to retrieve some PODS records. I am able to use the “orderby” parameter with no problem. If my PODS field is called “staff_name” for example, I can say ‘orderby’=>’staff_name ASC’ and everything works great. But when I try to use “where” with a PODS field, say something like ‘where’=>’staff_name = Smith’, the query errors out with an SQL error saying “Unknown column ‘staff_name’ in ‘where clause'”

    So I take it the orderby and where parameters use different syntax to specify the field names? I’ve read the Pods.io docs on the find() function (including the big table at the bottom) but there’s only a single where example and it searches on the WP post name field rather than a PODS field, so it isn’t much help. I tried prefixing the field name: t.staff_name and d.staff_name, etc but couldn’t find any combination that worked.

    What am I doing wrong? Can anyone explain how to correctly use the “where” parameter of find() to search on a PODS field?

    https://wordpress.org/plugins/pods/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    You probably want to use staff_name.meta_value

    See here at the bottom for a grid of how you can reference different types of fields on different types of Pods.

    http://pods.io/docs/code/pods/find/

    Thread Starter steevithak

    (@steevithak)

    Yes, that worked. Thanks! However, I had already seen the grid in the docs without being able to comprehend which case applied. There’s nothing in that grid on the Find documentation page that explains how to identify which row/column applies. For example, how would I know that in this case I was dealing with the “Custom Field [Meta-based]” row in the grid (and which column applied in this case – several suggest using the .meta_value postfix)? How is a user of the plugin intended to discover that information? Is there a debug area of the admin screen where I can dump this information about the fields in my POD? One or two actual examples of the usage would be a helpful addition to the Find documentation page. I appreciate the help – just pointing out that some minor improvements in the docs might have made it more clear to a new user!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to specify field name in the find() "where" parameter’ is closed to new replies.