First of all, use prepared statements.
The account id part is always the same, so extract it to the beginning.
Also, you can extract the isset and not empty part to a function to simplify the code.
$partQuery = 'account_id = '.$account->id;
if(isNotEmpty($phone) && isNotEmpty($email)) {
$partQuery .= ' AND (phone = "'.(int)$phone.'" OR email = "'.$email.'")';
}
if(isNotEmpty($phone)) {
$partQuery .= ' AND phone = "'.(int)$phone.'"';
}
if(isNotEmpty($email)) {
$partQuery .= ' AND email = "'. $email.'"';
}
function isNotEmpty($var) {
return isset($var) && !empty($var);
}
Although I would assume that that is not actually what you want, as it adds two additional ANDs in case neither phone nor email is empty.
It also seems like an odd query in general. You are fine with a wrong phone number as long as the email is correct and vise versa?
Also note that you don't actually need isset, you can just use !empty, it will not generate a warning.