Title: MySQL Errors with Formidable Forms
Last modified: August 3, 2020

---

# MySQL Errors with Formidable Forms

 *  Resolved [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/)
 * Can’t use this plugin when Formidable (Pro) is enabled:
 *     ```
       [Not unique table/alias: 'ham_postmeta']<br /><code>SELECT SQL_CALC_FOUND_ROWS DISTINCT ham_posts.ID FROM ham_posts  LEFT JOIN ham_postmeta ON (ham_posts.ID = ham_postmeta.post_id AND ham_postmeta.meta_key = '_frm_temporary' )  LEFT JOIN ham_postmeta AS mt1 ON (ham_posts.ID = mt1.post_id AND mt1.meta_key = '_frm_file' ) LEFT JOIN ham_postmeta ON ham_posts.ID = ham_postmeta.post_id  LEFT JOIN ham_postmeta AS sq1 ON ( ham_posts.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' ) WHERE 1=1  AND ( 
         ( 
           ham_postmeta.post_id IS NULL 
           AND 
           mt1.post_id IS NULL
         )
       ) AND ham_posts.post_type = 'attachment' AND ((ham_posts.post_status = 'inherit' OR ham_posts.post_status = 'private'))AND ID IN (-1) GROUP BY ham_posts.ID ORDER BY ham_posts.post_date DESC LIMIT 0, 200
       ```
   
 * i browsed code by _frm_temporary and this is what i found:
 *     ```
       /**
       	 * Set _frm_temporary and _frm_file metas
       	 * to use for media library filtering
       	 */
       	private static function add_meta_to_media( $media_ids, $type = 'temporary' ) {
       		foreach ( (array) $media_ids as $media_id ) {
       			if ( is_numeric( $media_id ) ) {
       				update_post_meta( $media_id, '_frm_' . $type, 1 );
       			}
       		}
       	}
   
       	/**
       	 * When an entry is saved, remove the temp flag
       	 */
       	private static function remove_meta_from_media( $media_ids ) {
       		foreach ( (array) $media_ids as $media_id ) {
       			if ( is_numeric( $media_id ) ) {
       				delete_post_meta( $media_id, '_frm_temporary' );
       			}
       		}
       	}
       ```
   
 *     ```
       public static function filter_media_library( $query ) {
       		if ( 'attachment' == $query->get( 'post_type' ) ) {
       			$meta_query = $query->get( 'meta_query' );
       			self::query_to_exclude_files( $meta_query );
   
       			$query->set( 'meta_query', $meta_query );
       		}
       	}
       private static function query_to_exclude_files( &$meta_query ) {
       		if ( current_user_can( 'frm_edit_entries' ) ) {
       			$show = FrmAppHelper::get_param( 'frm-attachment-filter', '', 'get', 'absint' );
       		} else {
       			$show = false;
       		}
   
       		if ( ! is_array( $meta_query ) ) {
       			$meta_query = array();
       		} else {
       			$continue = self::nest_attachment_query( $meta_query );
       			if ( ! $continue ) {
       				return;
       			}
       		}
   
       		$meta_query[] = array(
       			'relation' => 'AND',
       			array(
       				'key'     => '_frm_temporary',
       				'compare' => 'NOT EXISTS',
       			),
       			array(
       				'key'     => '_frm_file',
       				'compare' => $show ? 'EXISTS' : 'NOT EXISTS',
       			),
       		);
       	}
       ```
   
 * `add_action( 'pre_get_posts', 'FrmProFileField::filter_media_library', 99 );`
 * hope this helps to fix the error!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Ninja Team](https://wordpress.org/support/users/ninjateam/)
 * (@ninjateam)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13220252)
 * Hi there,
 * Thanks for reaching out. We checked but we do not see the issue, can you please
   send us screenshots/screencast or error notice, error logs in details?
    Thank
   you so much.
 * Best regards,
    Kelly
 *  Thread Starter [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13230849)
 * i tried to reproduce again but seems error is gone for now! may i ask you a different
   question? how are folders managed? do you use a regular wordpress taxonomy in
   the background? asking this for wp_query function.
 *  Plugin Support [Bruce](https://wordpress.org/support/users/ninjateamwp/)
 * (@ninjateamwp)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13248868)
 * Hi there,
 * I am glad to know that the previous errors were resolved now.
    Regarding your
   question! Please note that we don’t use ‘taxonomy’ like the old version (3.9 
   and earlier) anymore. We now create fbv_tables in the database to manage the 
   folders.
 * Thank you.
 * Kind regards,
    -Bruce-
 *  Thread Starter [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13248907)
 * okay and is there some sample code to query images by a specific folder name/
   id ?
 *  Plugin Author [Ninja Team](https://wordpress.org/support/users/ninjateam/)
 * (@ninjateam)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13290821)
 * Hi [@nicmare](https://wordpress.org/support/users/nicmare/),
 * Sorry for the late response, we missed your comment.
 * This is the code that helps:
 *     ```
       $query = new WP_Query([
       ‘post_status’ => ‘inherit’,
       ‘post_type’=> ‘attachment’,
       ‘post_mime_type’ =>array(
       ‘jpg|jpeg|jpe’ => ‘image/jpeg’,
       ‘gif’ => ‘image/gif’,
       ‘png’ => ‘image/png’,
       ),
       ‘orderby’ => ‘rand’,
       ‘posts_per_page’ => 5,
       ‘post__in’ => $wpdb->get_col(“SELECT attachment_id FROM ” . $wpdb->prefix . “fbv_attachment_folder WHERE folder_id = your_folder_id”)
       ]);
       ```
   
 * Also, please see the API documentation in case you need it sometimes:
    [https://ninjateam.gitbook.io/filebird/api](https://ninjateam.gitbook.io/filebird/api)
 * Thanks and let us know if you need anything else.
 * Kind regards,
    Kelly
    -  This reply was modified 5 years, 9 months ago by [Ninja Team](https://wordpress.org/support/users/ninjateam/).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘MySQL Errors with Formidable Forms’ is closed to new replies.

 * ![](https://ps.w.org/filebird/assets/icon-128x128.gif?rev=2299145)
 * [FileBird - WordPress Media Library Folders & File Manager](https://wordpress.org/plugins/filebird/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/filebird/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/filebird/)
 * [Active Topics](https://wordpress.org/support/plugin/filebird/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/filebird/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/filebird/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Ninja Team](https://wordpress.org/support/users/ninjateam/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/mysql-errors-with-formidable-forms/#post-13290821)
 * Status: resolved