0
我在wpdb类引用上的插入示例之后创建插入查询。什么sprintf像占位符应该用于自定义表格上的DateTime列?允许的占位符似乎是%s(字符串),%d(整数)和%f(float)。在我的例子中,我已经设置DateTime列使用%s字符串值,这是正确的吗?WordPress数据库:自定义表格:DateTime列的sprintf值
下面的例子简化了我的情况。
表创建
global $wpdb;
$sql = "CREATE TABLE $wpdb->prefix. 'time' (
id bigint(20) NOT NULL AUTO_INCREMENT,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
UNIQUE KEY id (id)
)";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
插入
$wpdb->insert(
$wpdb->prefix. 'time',
array(
'time' => current_time('mysql')
),
array(
'%s'
)
);
我已经使用下面所链接的类WPDB参考。 http://codex.wordpress.org/Class_Reference/wpdb#Placeholders