function GetCount($sql) { try { $conn = new MyDb(); $count = $conn->GetCount($sql); if ($count) { $conn->Close(); return $count; } } catch (Exception $e) { $conn->Close(); echo $e->getMessage(); } $conn->Close(); return 0; }