fix: Resolve PHP errors in Certificate Manager SQL query construction
- Fix duplicate WHERE clause construction in get_user_certificate_count method - Remove incorrect AND operator placement in search query - Streamline SQL query building logic for better reliability - All certificate functionality now working without PHP errors - Comprehensive testing confirms all pages load correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
08e4d412bb
commit
d7773b5d04
1 changed files with 18 additions and 41 deletions
|
|
@ -683,14 +683,10 @@ class HVAC_Certificate_Manager {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Build WHERE clause
|
||||
$where_clause = !empty($where) ? "WHERE " . implode(" AND ", $where) : "";
|
||||
|
||||
// Add WHERE clause for attendee search if provided
|
||||
if (!empty($args['search_attendee'])) {
|
||||
$search_term = '%' . $wpdb->esc_like($args['search_attendee']) . '%';
|
||||
|
||||
if (empty($where)) {
|
||||
$where[] = "(
|
||||
certificate_id IN (
|
||||
SELECT c.certificate_id
|
||||
|
|
@ -708,29 +704,10 @@ class HVAC_Certificate_Manager {
|
|||
)";
|
||||
$where_values[] = $search_term;
|
||||
$where_values[] = $search_term;
|
||||
} else {
|
||||
$where[] = "AND (
|
||||
certificate_id IN (
|
||||
SELECT c.certificate_id
|
||||
FROM {$wpdb->prefix}hvac_certificates c
|
||||
JOIN {$wpdb->postmeta} pm ON c.attendee_id = pm.post_id
|
||||
WHERE pm.meta_key = '_tribe_tickets_full_name' AND pm.meta_value LIKE %s
|
||||
)
|
||||
OR
|
||||
certificate_id IN (
|
||||
SELECT c.certificate_id
|
||||
FROM {$wpdb->prefix}hvac_certificates c
|
||||
JOIN {$wpdb->postmeta} pm ON c.attendee_id = pm.post_id
|
||||
WHERE pm.meta_key = '_tribe_tickets_email' AND pm.meta_value LIKE %s
|
||||
)
|
||||
)";
|
||||
$where_values[] = $search_term;
|
||||
$where_values[] = $search_term;
|
||||
}
|
||||
}
|
||||
|
||||
// Build WHERE clause
|
||||
$where_clause = !empty($where) ? "WHERE " . implode(" ", $where) : "";
|
||||
$where_clause = !empty($where) ? "WHERE " . implode(" AND ", $where) : "";
|
||||
|
||||
// Build final query
|
||||
$query = "SELECT COUNT(*) FROM {$wpdb->prefix}hvac_certificates $where_clause";
|
||||
|
|
|
|||
Loading…
Reference in a new issue