我無法找到自定義查詢的任何語法,使用$ wpdb對我來說是新的,所以任何人都可以幫助我解決這個問題?Wordpress數據庫自定義查詢來驗證數據
if(isset($_POST['submit']))
{
global $wpdb;
$tablename='wp_form_subscribe';
$myrows = $wpdb->get_results("SELECT * FROM wp_form_subscribe where email=$wpdb->email");
if($myrows==0)
{
$data=array(
'name' => $_POST['fullname'],
'age' => $_POST['age'],
'email' => $_POST['email']);
$wpdb->insert($tablename, $data);
}
else
{
$status='User already subscribed';
}
$status='';
}
經過以下文章:https://codex.wordpress.org/Class_Reference/wpdb –