WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 2 months ago

Last modified 2 months ago

#41929 closed defect (bug) (duplicate)

Bug wpdb prepare 4.8.2

Reported by: victorfreitas Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.2
Component: Query Keywords:
Focuses: Cc:

Description

After updating to 4.8.2, my SQL query in prepare method not working.

Code example:

<?php
        $results = $wpdb->get_results(
                $wpdb->prepare(
                        "SELECT
                                `ID`
                         FROM
                                `{$wpdb->posts}`
                         WHERE
                                `ID` = %1\$d
                         AND
                                `post_status` = '%2\$s'
                        ",
                        100,
                        'publish'
                )
        );

Change History (2)

#1 follow-up: @ocean90
2 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hello @victorfreitas, numbered placeholders are not supported by wpdb::prepare(), see #41926 and #41925.

#2 in reply to: ↑ 1 @victorfreitas
2 months ago

Replying to ocean90:

Thank you @ocean90 for the feedback.

Note: See TracTickets for help on using tickets.