Pass your information through prepare
如《法典》中的本例所示:
$metakey = "Harriet\'s Adages";
$metavalue = "WordPress\' database interface is like Sunday Morning: Easy.";
$wpdb->query( $wpdb->prepare(
"
INSERT INTO $wpdb->postmeta
( post_id, meta_key, meta_value )
VALUES ( %d, %s, %s )
",
array(
10,
$metakey,
$metavalue
)
) );
数组的元素数应与查询字符串的占位符数相同。