📜  wpdb 计数 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:51.755000             🧑  作者: Mango

代码示例1
### Search for IP in database
function postviews_get_ip($id, $ip) {
    global $post, $wpdb;

    $ipquery= $wpdb->get_results("SELECT * FROM $wpdb->wp_postviews_ips WHERE postid = $id AND ip = '$ip'");
    $rowcount = $ipquery->num_rows;
    return $rowcount;
}

postviews_get_ip($id, $_SERVER['REMOTE_ADDR']);
//both $id and $_SERVER['REMOTE_ADDR']) return the values I'm searching for in the database