SQL syntax error near '`mbr_order` ASC, mbr_id DESC ASC'
Support › MB Relationships › SQL syntax error near '`mbr_order` ASC, mbr_id DESC ASC'Resolved
- This topic has 7 replies, 2 voices, and was last updated 3 years, 10 months ago by
Stefan Grassberger.
-
AuthorPosts
-
May 13, 2021 at 5:47 PM #28156
Stefan Grassberger
ParticipantHello,
I'm using versions:Meta Box 5.4.0
Meta Box AIO 1.13.9and I'm trying to setup a reciprocal relationship between two terms of a custom taxonomy:
MB_Relationships_API::register( [ 'id' => 'rbi_neighboring_countries', 'reciprocal' => true, 'from' => [ 'object_type' => 'term', 'taxonomy' => 'rbi_country', 'meta_box' => [ 'title' => 'Neighboring countries', ], ], 'to' => [ 'object_type' => 'term', 'taxonomy' => 'rbi_country', ], ] );
The code on the archive page:
<?php $terms = get_terms( array( 'taxonomy' => 'rbi_country', 'hide_empty' => false, 'relationship' => array( 'id' => 'rbi_neighboring_countries', 'to' => get_queried_object()->term_id, ), ) ); foreach ( $terms as $t ) { echo esc_html( $t->name ); } ?>
This error is displayed in the frontend:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
mbr_orderASC, mbr_id DESC ASC' at line 1]
SELECT t.*, tt.* , mbr.from AS mbr_from, mbr.to AS mbr_to, mbr.ID AS mbr_id, CASE WHEN mbr.to = t.term_id THEN mbr.order_from WHEN mbr.from = t.term_id THEN mbr.order_to END AS <code>mbr_order</code> FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_mb_relationships AS mbr ON (mbr.type = 'rbi_neighboring_countries' AND ((mbr.from = t.term_id AND mbr.to IN (1)) OR (mbr.to = t.term_id AND mbr.from IN (1)))) WHERE tt.taxonomy IN ('rbi_country') <code>mbr_order</code> ASC, mbr_id DESC ASCSeems to me like
DESC ASC
is the issue?May 14, 2021 at 12:11 PM #28177Long Nguyen
ModeratorHi,
Thank you for your feedback.
I'm going to check this issue and get back to you later.
May 14, 2021 at 3:50 PM #28182Stefan Grassberger
ParticipantThanks!
May 24, 2021 at 5:59 PM #28389Stefan Grassberger
ParticipantHi Long,
were you able to reproduce the issue?May 25, 2021 at 10:49 AM #28399Long Nguyen
ModeratorHi Stefan,
It was an issue of reciprocal option when using the term object. I've escalated it to the development team to fix it in the next update.
May 25, 2021 at 3:56 PM #28408Stefan Grassberger
ParticipantGreat news, thank you so much!
June 27, 2021 at 9:53 PM #29154Long Nguyen
ModeratorHi,
This issue has been fixed on this commit. Can you please check it and let me know if it works?
June 30, 2021 at 7:43 PM #29219Stefan Grassberger
ParticipantI tested with the plugin at the commit and I can confirm it fixes the issue!
Thank you, looking forward to the next release 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.