[wp-hackers] Plugins using hardcoded table prefix

Owen Winkler ringmaster at midnightcircus.com
Mon Mar 21 12:16:51 GMT 2005


Mark Jaquith wrote:

> Alex King wrote:
>
>> Weren't these variables just added in 1.5? I thought they were added 
>> recently.
>>
>> Also, be aware that when using these variables (or any object 
>> properties) I'm pretty sure you can't just stick them inside a 
>> double-quoted string. 
>
> They were added fairly early on in WP 1.3, last summer, I'd say.  
> Quite a lot of plugin writers started writing plugins for WP 1.3 CVS 
> code, so this shouldn't be anything new to them.
>
> Alex, if you weren't able to put $wpdb->posts and the like into 
> doublequoted strings, WordPress wouldn't get past the install phase.  
> It's pretty much the standard way of doing it.  Your test environment 
> must be screwy.

This works:

$sql = "SELECT * FROM {$wpdb->posts} WHERE ...";

I usually add my own table variables to $wpdb using the $table_prefix 
variable, then only reference what I've added to $wpdb.  I makes 
everything look consistent.

Owen






More information about the wp-hackers mailing list