Merge pull request #784 from yitam/fixCount

Check if returned error is empty first before using count()
This commit is contained in:
Jenny Tam 2018-05-29 13:55:40 -07:00 committed by GitHub
commit 99b91f8059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -414,10 +414,16 @@ function printErrors($message = "")
echo $message . "\n";
}
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
if (count($errors) == 0) {
$count = 0;
if (!empty($errors)) {
$count = count($errors);
} else {
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
if (!empty($errors)) {
$count = count($errors);
}
}
$count = count($errors);
for ($i = 0; $i < $count; $i++) {
echo $errors[$i]['message'] . "\n";
}
@ -427,12 +433,11 @@ function handleErrors()
{
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
$count = 0;
$count = 0;
if (! empty($errors)) {
if (!empty($errors)) {
$count = count($errors);
} else {
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
if (! empty($errors)) {
if (!empty($errors)) {
$count = count($errors);
}
}