[wp-trac] [WordPress Trac] #2862: SQL formatting method for WPDB
WordPress Trac
wp-trac at lists.automattic.com
Sun Jun 25 16:30:57 GMT 2006
#2862: SQL formatting method for WPDB
------------------------+---------------------------------------------------
Reporter: DevaSatyam | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: General | Version:
Severity: minor | Keywords:
------------------------+---------------------------------------------------
Added a BuildSql method to wpdb. It works, more or less, like a sprintf
but oriented towards SQL and WordPress. Escape character is ? followed by
a letters indicating the type of data to be inserted and some options. It
includes a ?t which adds the contents of $table_prefix. After the first
argument, the SQL statement with the ?xxx placeholders, there can be any
number of arguments which are inserted into the string as indicated by the
datatype and options.
{{{
echo BuildSql('Insert into ?ttable
(?s,?ns,?mi,?d,?ni,?i)','Something','',5,time(),0,null);
}}}
will return:
{{{
Insert into wp_table ('Something',null,5,'2006-05-15',null,0)
}}}
It contains a PhpDocumenter-style heading with all the options. I was
not able to get this version of WP working so I copied the version I'm
using on my production site and made some minor modifications to make it
self-contained (not dependent on some other functions of mine) which I was
unable to test, sorry.
--
Ticket URL: <http://trac.wordpress.org/ticket/2862>
WordPress Trac <http://wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list