Welcome Guest, Not a member yet? Register   Sign In
Joining tables in two dbs
#10

[eluser]Eric Brown[/eluser]
Example Query (forgive any errors)
Code:
$sql = <<<SQL
select      a.user_id, b.user_id, b._first_name
from        site_db1.users a
left join   site_db2.user_details b
on         a.user_id = b.user_id
where       date(from_unixtime(b.reg_date)) = adddate(date(now()), -1)
and         a.active = 1;
SQL;

$query = $this->aggregation_db->query($sql);

DBs:
Code:
$db['default']['hostname'] = "10.1.1.1";
$db['default']['username'] = "db_user";
$db['default']['password'] = "password1";
$db['default']['database'] = "site_db1";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

$db['aggregation']['hostname'] = "10.1.1.2";
$db['aggregation']['username'] = "db_user";
$db['aggregation']['password'] = "password_1";
$db['aggregation']['database'] = "site_db2";
$db['aggregation']['dbdriver'] = "mysql";
$db['aggregation']['dbprefix'] = "";
$db['aggregation']['pconnect'] = TRUE;
$db['aggregation']['db_debug'] = TRUE;
$db['aggregation']['cache_on'] = FALSE;
$db['aggregation']['cachedir'] = "";
$db['aggregation']['char_set'] = "utf8";
$db['aggregation']['dbcollat'] = "utf8_general_ci";


Messages In This Thread
Joining tables in two dbs - by El Forum - 05-18-2010, 10:21 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:36 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:45 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:46 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:47 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:50 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:52 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 10:58 PM
Joining tables in two dbs - by El Forum - 05-18-2010, 11:01 PM
Joining tables in two dbs - by El Forum - 05-19-2010, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB