/** * This function generates a "IN" query for a given array * * @global object $wpdb * @param string $model_identifier * @param string $column_to_search name of the column to search for the values in the array * @param array $types_array array of values. * @return array */ public static function get_results_for_array($model_identifier, $column_to_search, array $types_array) { global $wpdb; $table_name = RM_Table_Tech::get_table_name_for($model_identifier); $qry = "SELECT * FROM `{$table_name}` WHERE `{$column_to_search}` IN ("; $i = 0; foreach ($types_array as $type) { if ($i != 0) { $qry .= ","; } $qry .= "'{$type}'"; $i++; } $qry .= ")"; $result = $wpdb->get_results($qry); return $result; }