1. Home
  2. Docs
  3. Simpods MVC
  4. Tutorials
  5. Featured Methods
  6. simpods_select()

simpods_select()

simpods_select is built to facilitate data queries for some Simpods components like Hierarchy and Linked Area, but you can use it as a normal query function.

Parameters

simpods_select accepts four parameters:

simpods_select( $fields = array(), $attributes = array(), $can_echo_query = false, $can_prefix = true )
  • $fields: Pass in an associated array to search table fields, in this format: array(‘field_name’ => ‘value’). For example, if you want an exact match of “hello” in post_name, create an array like this: array(‘post_name’ => ‘hello’); To search one value in many options, arrange the options in an array, e.g. array( ‘post_status’ => array(‘publish’, ‘pending’) ). Combining the two examples above, the $fields_arr will be
    array('post_name' => 'hello', 'post_status'  => array('publish', 'pending') )
    

    If a Pods table is the main table you are querying, please add post_tb. before the fields of the WordPress posts table, e.g.

    array('post_tb.post_name' => 'hello', 'post_tb.post_status'  => array('publish', 'pending') )
    

    There some prefixes to added to the field_name to meet different search criteria:

    • _exc_ Search will return all rows except those with the field that matches the value. e.g. array(‘_exc_post_name’ => ‘hello’);
    • _find_ Search will return all rows with the field that contains the value. e.g. array(‘_find_post_name’ => ‘hello’);
    • _prev_ If search order is set to ASC, search will return the row previous to the one that contains the value. e.g. array(‘_prev_post_name’ => ‘hello’);
    • _next_ If search order is set to ASC, search will return the row after to the one that contains the value. e.g. array(‘_next_post_name’ => ‘hello’);
  • $attributes: Pass in an associated array to construct the query, in this format: array(‘key’ => ‘value’).  Below is the default one. If your keys are not listed in the default array, they will be ignored. If they exist, your values will overwrite the existing ones.

Copy to Clipboard