Doğrudan JS içinde yapamazsınız.
SQL sorgularını çalıştırıp, sonucu döndürecek bir PHP API oluşturmanız gerekiyor.