• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Notes to Self

  • Aviation Weather from NOAA Plugin
    • KZZV
    • Bad Shortcode
    • Simple Metar
  • Meetings
  • Meetings Map

Mark Chouinard / January 27, 2013

$wpdb::prepare()

I thought $wpdb->prepare() had been working for me.  I really did.  What I hadn’t realized, or taken the time to learn, was that prepare() functions similarly to printf(), taking placeholders for arguments provided after the query that is being prepared, i.e. $wpdb->prepare("SELECT * FROM table_name WHERE id = %d AND title = %s SORT BY date DESC", $id, $title); with %d representing an int ($id) and %s representing a string ($title).

Using it with my query as the only argument, prepare() wasn’t having any effect on it at all.  Not that my queries were trash, but Garbage In, Garbage Out so to speak.

 

Filed Under: WordPress

Primary Sidebar

Footer

Copyright © 2021 · machouinard · Log in