How can including different databases in a single PHP function impact performance and security?

Including different databases in a single PHP function can impact performance and security because it can lead to complex queries and potential vulnerabilities if not handled properly. To address this issue, it is recommended to create separate functions for each database connection and operation to ensure better organization, maintainability, and security.

function queryDatabase1($sql) {
    $conn1 = new mysqli("localhost", "username1", "password1", "database1");
    // Perform query using $conn1
}

function queryDatabase2($sql) {
    $conn2 = new mysqli("localhost", "username2", "password2", "database2");
    // Perform query using $conn2
}