Here's a twisty one I hope someone out there can help me with. There's probably an easy solution, but I tend to complicate things and work my way back from there
Objective:
Connect to 10 databases different databases through MySQL ODBC 3.51
that have the same name, same table names, same field names etc. simultaneously and run one query.
Reason:
Aggregate reporting from 10 different companies created in simply accounting that cannot be consolidated.
Question:
Can I connect to all databases using a variable or function and use that variable or function name to run one single query on all the databases at once?
What I've Tried
<?php
//Connection Variables
$username = "Paul";
$password = "pau345j";
$port1 = "13540";
$port2 = "13541";
//ODBC Connections
$EGL = odbc_connect($port1,$username,$password);
$OCI = odbc_connect($port2,$username,$password);
$multi = array($EGL,$OCI);
//Query and result for Everlast
$sql="SELECT * FROM tcompany";
$rs=odbc_exec($multi,$sql);
while (odbc_fetch_row($rs))
{
$lId = odbc_result($rs, "lId");
$sCompName = odbc_result($rs, "sCompName");
echo "<table width='100%' cellpadding='0' cellspacing='0'>
<tr>
<td class='table_data_L'>$lId</td>
<td class='table_data_R'>$sCompName</td>
</tr>
<table>";
}
?>
And Finally, The error Messages
Warning: odbc_exec() expects parameter 1 to be resource, array given in C:\xampp\htdocs\array_sandbox.php on line 34
Warning: odbc_fetch_row() expects parameter 1 to be resource, null given in C:\xampp\htdocs\array_sandbox.php on line 38