Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Connection to external databases


tmckinnon

Recommended Posts

I am trying to access a number of legacy databases from oscommerce.

After my initial investigation I thought I could do something like the following:

 

 

tep_db_connect(DB_LEGACY1_SERVER, DB_LEGACY1_SERVER_USERNAME, DB_LEGACY1_SERVER_PASSWORD, DB_LEGACY1_DATABASE, LEGACY1_db_link');

$temp_query = tep_db_query("SELECT count(*) as count from app_user", 'legacy1_db_link');

$temp_ent = tep_db_fetch_array($temp_query, 'legacy1_db_link');

tep_db_close('legacy1_db_link');

 

But this doesn't appear to do anything. The call to tep_db_query still goes against the main osc connection.

 

Anyway to do this?

 

Cheers

Link to comment
Share on other sites

I am trying to access a number of legacy databases from oscommerce.

After my initial investigation I thought I could do something like the following:

tep_db_connect(DB_LEGACY1_SERVER, DB_LEGACY1_SERVER_USERNAME, DB_LEGACY1_SERVER_PASSWORD, DB_LEGACY1_DATABASE, LEGACY1_db_link');

$temp_query = tep_db_query("SELECT count(*) as count from app_user", 'legacy1_db_link');

$temp_ent = tep_db_fetch_array($temp_query, 'legacy1_db_link');

tep_db_close('legacy1_db_link');

 

But this doesn't appear to do anything. The call to tep_db_query still goes against the main osc connection.

 

Anyway to do this?

 

 

add connection string parameters to the configure.php file

create new functions to connect to and query the new db in the includes/functions/database.php file

 

Corrie

Link to comment
Share on other sites

add connection string parameters to the configure.php file

create new functions to connect to and query the new db in the includes/functions/database.php file

 

Corrie

 

 

I did this:

 

tep_iqdb_connect(DB_LEGACY_SERVER, DB_LEGACY_SERVER_USERNAME, DB_LEGACY_SERVER_PASSWORD, DB_LEGACY_DATABASE, 'LEGACY_db_link') or die('Unable to connect to LEGACY database server!');

$temp_LEGACY_query = tep_iqdb_query("SELECT count(*) as count from app_user", 'LEGACY_db_link');

$temp_LEGACY = tep_db_fetch_array($temp_LEGACY_query);

print_r($temp_LEGACY);

tep_iqdb_close('LEGACY_db_link');

 

 

Where in: database.php I reimplemented all functions with theh $$link = 'db_link' to use the new constants.

 

When I try the code above it still says:

 

1146 - Table 'osc_dev.app_user' doesn't exist

SELECT count(*) as count from app_user

[TEP STOP]

 

The new db should be legacy_test.app_user.

 

Am I missing something else?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...