WordPress prepared LIKE query [on hold]

I’m trying to use a prepared LIKE query within WordPress, but it doesn’t seem to be working. I’ve followed the codex for the syntax.

public function userByJobId($id){        
    global $wpdb;
    $result = $wpdb->get_row($wpdb->prepare( "SELECT * FROM use_users WHERE use_job_id LIKE = d%;", '%' . $wpdb->esc_like((int)$id)) . '%');

    if(!empty($result)){
       return $result;
    }
    return false;
}

Calling the method like so:

$userid = 1
$user = new Users();
$user_id = $user->userByJobId($userid);

Cant see where the issue lies..


Source: wpdb

Leave a Reply