get_results()
by default returns each databse row as object, so $survey_mapping
is an array of objects. Therefore you should replace $row
with $row->surveyid
in the second query:
$dup_survey2 = absint( $wpdb->get_var(
$wpdb->prepare("SELECT surveyls_survey_id FROM oc_surveys_languagesettings WHERE surveyls_survey_id = %d", $row->surveyid)
));
and in $wpdb->delete()
:
array('surveyid' => absint($row->surveyid))
By the way, you can use a single SQL query that removes entries from oc_partner_x_survey
that have no match in oc_surveys_languagesettings
:
DELETE oc_partner_x_survey
FROM oc_partner_x_survey
LEFT JOIN oc_surveys_languagesettings ON oc_surveys_languagesettings.surveyls_survey_id = oc_partner_x_survey.surveyid
WHERE
oc_surveys_languagesettings.surveyls_survey_id IS NULL
Related Posts:
- MySQL “Or” Condition
- How to correctly submit a search form and display the result in an independent page
- Select dropdown not showing selected value php
- how to save selection meta data in user profile on frontend
- How to make drop down post title
- Multiple options not staying selected after saving
- Custom profile field with birthday. Troubles with
- Filter Select results based on selection
- Long running queries
- wp_dropdown_pages auto submit
- How to convert select to HTML with PHP tags inside of it [closed]
- add onchange to select in a wp form
- HTML dropdown setting not showing last saved value in the database
- Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts
- Custom Taxonomy Select Menu: Setting default option value?
- Add a select-option to the default widgets
- Compare current post Category in select menu
- How to set value selected using select2 jquery plugin
- Database SQL query error
- How to make a pagination with dropdown selection?
- Reload page with a different shortcode when a user selects from a dropdown
- Echo Option Value Based On WordPress User Role
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- Open WordPress Page from selected option dropdown
- User registration followed by automatic login
- wp_insert_user role not working
- How to find cause of PHP notices with no stack trace?
- How to paginate a list of custom taxonomy terms?
- reason of splitting theme files to multiple files
- wordpress separate registration for different roles
- Problem with Woocommerce REST API Authentication
- How to get custom image size for image uploaded in Customizer
- Passing POST data from one WP post to another
- register_activation_hook isn’t adding table to DB
- how to get the value of time left for a transient
- is_page “range” for if statement?
- How to Fetch values from WP database based on selected option value by onchange using PHP?
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How to create a custom category of wordpress admin
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Customizer: Output default value in Customizer CSS
- Converting HTML Template to WordPress Theme
- PHP Warning: chmod(): Operation not permitted in class-wp-filesystem-direct.php on line 173
- WordPress asks you for your FTP details if you want to run Automatic Updates/Upgrade Plugins
- 404 error when I acess the second page of post-type
- Where can I create a normal php file?
- Trying do build a contact form
- How to Disable WordPress Page Revisions?
- Prev/Next Links Broken on Static Front Page Pagination
- How to integrate noimage picture in this code
- get comment data using comment id
- $_SESSION variables work perfectly on my local machine but returns NULL on development webserver
- Creating black and white copy of an image [closed]
- preg_replace on all HTML content in WordPress
- Post class only applying to first excerpt; why?
- Add categorys to custom post type not working
- call adminbar greeting in other place
- PHP Warning: preg_match() expects & PHP Warning: strip_tags()
- Limit the number of child pages
- WP_LINK_PAGES Generating Unnecessary Tag
- Why is home page content not displaying with this rewrite rule?
- How to show upcoming events according to start date field
- Some problems in custom widget
- Call a function in functions.php from within tags (JS)
- Displaying images outside the content
- WordPress Conditional / Multiple Taxonomy Query
- Add class to ul and li in wp_na
- Can I ‘order by’ date that is in a text field?
- Show related products by attribute based and certain conditions
- How to retrieve taxonomy Metabox fields in frontend
- PHP function for horizontal Woocommerce thumbnails and badges
- Creating a Function and Call It
- How to count active users on a specific page
- WooCommerce display price before add to cart [closed]
- Create dashboard widget for custom theme support
- The style.php file inside theme-engine folder has other content on FTP
- WordPress ajax filter returning all posts when it should be filtering by category
- WooCommerce Quantity in Dropdown menu instead of clasic [closed]
- How to override html codes in wordpress?
- Plugin Modification Change Functionality For Logged User Only
- How can I output the slug of a comment author?
- customizer live preview layout picker
- Display tab title as ‘blog tagline | blog title’
- Conditional statement within WP SQL query
- Modify category archive page loop on functions.php
- How to display html code on homepage
- two wordpress sites, two themes, one database, same content
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- Php conditional help needed
- Adapting a php array to WordPress
- Different layout on search page depending on category post
- Dynamically pull the correct email address from a match
- New to wordpress. Need Help with templates [closed]
- Issues trying to add a href statment with PHP into a PHP Echo Statement [closed]
- Help with if/else loop [closed]
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to set variable to specific field when querying
- How to lock users account until approvation