| @@ -805,9 +805,12 @@ | ||
| 805 | 805 | */ |
| 806 | 806 | public function update_ticket_count() { |
| 807 | 807 | |
| 808 | 808 | global $wpdb; |
| 809 | - $count = $wpdb->get_var( "SELECT count(id) from {$wpdb->prefix}psmsc_tickets WHERE is_active=1 AND customer=" . $this->id ); | |
| 809 | + if ( ! is_numeric( $this->id ) || (int) $this->id <= 0 ) { | |
| 810 | + return; | |
| 811 | + } | |
| 812 | + $count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$wpdb->prefix}psmsc_tickets WHERE is_active=1 AND customer=%d", $this->id ) ); | |
| 810 | 813 | $this->ticket_count = $count; |
| 811 | 814 | $this->save(); |
| 812 | 815 | } |
| 813 | 816 | |