|
I do not know if it will work but you can get data from another databse with the syntax
`database_name.`table_name`.`field_name`
instead of the usual `table_name`.`field_name`
but as for doing an insert query into another database, you would have to open another connection so you will need to define another user and password and database name and then make $conn2, then you could try Update `database`.`table` set `database`.`table`.`field` = data() and see if it works, or even insert into `database`.`table` values.........
give it a go on a test rig and let us know how it goes, various others ahve asked and been told NO, but I have managed to get data from another database, but I have not tried inserting into another.
Good Luck OK, I have had a look in /include/dbcommon.php and the following variables are set in there
$host, $user, $pwd, $port and $sys_dbname then in dbconnection.php we get this build up of the $conn variable
function db_connect()
{
global $host,$user,$pwd,$errstr,$sys_dbname,$port;
$strhost=$host;
if($port && $port!=3306)
$strhost=$strhost.":".$port;
$conn = mysql_connect($strhost,$user,$pwd);
if (!$conn || !mysql_select_db($sys_dbname,$conn))
{
trigger_error(mysql_error(), E_USER_ERROR);
}
return $conn;
} So if we add a suffix of 2 to each of the connection variables, thus $host2, $user2, $pwd2, $port2 and $sys_dbname2 then change the function build up as follows
function db_connect2()
{
global $host2,$user2,$pwd2,$errstr2,$sys_dbname2,$port2;
$strhost2=$host2;
if($port2 && $port2!=3306)
$strhost2=$strhost2.":".$port2;
$conn2 = mysql_connect($strhost2,$user2,$pwd2);
if (!$conn2 || !mysql_select_db($sys_dbname2,$conn2))
{
trigger_error(mysql_error(), E_USER_ERROR);
}
return $conn2;
} then where you need to access the second database, use the $conn2 connection and see how it goes.
Please remember to close the connection to the second database after you have used the update or insert query. Let us know if it works please.
Remember, try this on Dummy data on a test rig so you cannot screw up your live data.
|