Advertisement
Guest User

RelationShips Problem

a guest
Nov 19th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /**
  2. * Delete all relationships to an object.
  3. *
  4. * @param int $object_id ID of the object metadata is for.
  5. * @param string $type The relationship type.
  6. * @param string $target The relationship target.
  7. */
  8. protected function delete_object_relationships( $object_id, $type, $target ) {
  9. global $wpdb;
  10.  
  11. $sql = $target
  12. ? "DELETE FROM $wpdb->mb_relationships WHERE `type`=%s AND `$target`=%d"
  13. : "DELETE FROM $wpdb->mb_relationships WHERE `type`=%s AND (`from`=%d OR `to`=%d)";
  14.  
  15. $wpdb->query(
  16. $wpdb->prepare(
  17. $sql,
  18. $type,
  19. $object_id,
  20. $object_id // <-- Problem is this argument
  21. )
  22. );
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement