<?php
function getWhereSql($id, $fio, $phone){
$whereArr[] = 'id = ' . intval($id); }
$whereArr[] = "fio LIKE '%" . $fio. "%'";
}
$whereArr[] = "phone LIKE '%" . $phone. "%'";
}
echo "ERROR, empty data \n";
} else {
echo "WHERE " . implode(' AND ', $whereArr) . "\n"; }
}
getWhereSql(1, 'Миша Маваши', 12345678);
getWhereSql(null, 'Миша Маваши', null);
getWhereSql(null, null, null);
PD9waHAKCmZ1bmN0aW9uIGdldFdoZXJlU3FsKCRpZCwgJGZpbywgJHBob25lKXsKICAgJHdoZXJlQXJyID0gYXJyYXkoKTsKICAgaWYoIWVtcHR5KCRpZCkpewogICAJICAgJHdoZXJlQXJyW10gPSAnaWQgPSAnIC4gaW50dmFsKCRpZCk7CiAgIH0KICAgCiAgIGlmKCFlbXB0eSgkZmlvKSl7CiAgIAkgICAkd2hlcmVBcnJbXSA9ICJmaW8gTElLRSAnJSIgLiAkZmlvLiAiJSciOwogICB9CiAgIAogICBpZighZW1wdHkoJHBob25lKSl7CiAgIAkgICAkd2hlcmVBcnJbXSA9ICJwaG9uZSBMSUtFICclIiAuICRwaG9uZS4gIiUnIjsKICAgfQogICAKICAgaWYoZW1wdHkoJHdoZXJlQXJyKSl7CiAgIAkgIGVjaG8gIkVSUk9SLCBlbXB0eSBkYXRhIFxuIjsKICAgfSBlbHNlIHsKICAgCSAgZWNobyAiV0hFUkUgIiAuIGltcGxvZGUoJyBBTkQgJywgJHdoZXJlQXJyKSAuICJcbiI7CiAgIH0KfQoKZ2V0V2hlcmVTcWwoMSwgJ9Cc0LjRiNCwINCc0LDQstCw0YjQuCcsIDEyMzQ1Njc4KTsKZ2V0V2hlcmVTcWwobnVsbCwgJ9Cc0LjRiNCwINCc0LDQstCw0YjQuCcsIG51bGwpOwpnZXRXaGVyZVNxbChudWxsLCBudWxsLCBudWxsKTsK