Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multiple shops - interrogate all databases?


chrish123

Recommended Posts

Posted

Hi,

 

I work for a small company that have multiple shops using very heavily modified RC1 shop codebase which is duplicated and always updated (nearly a years worth of custom daily work) so I cant use the Virtual mall addon contributions...

 

How can I view all the databases for outstanding orders from one page across all sites? Is there anything avaiable commercially or free which can do this?

 

Is there anyway in php to connect to more than 1 osc database at a time?

 

Any help very much appreciated!

Chris

Posted

Something like this will do it ..

 

class multiConnect{

 var $host = '';
 var $user = '';
 var $pass = '';
 var $dbname = '';
 var $link;

 function multiConnect(){

 }

 function getSingleton($host, $user, $pass, $dbname){

if( false !== is_null($this->link) ){
  $this->setParams($host, $user, $pass, $dbname);
  $this->dbGetResource();
} elseif( ($host != $this->host) || ($user != $this->user) || ($pass != $this->pass) || ($dbname != $this->dbname) ){
  $this->dbDisconnect();
  $this->setParams($host, $user, $pass, $dbname);
  $this->dbGetResource();	  
} else {
  // Use same old link
}

 }

 function dbGetResource(){
$this->link = mysql_connect($this->host, $this->user, $this->pass);
$this->dbConnect();
 }

 function dbDisconnect(){
mysql_close($this->link);
 }

 function setParams($host, $user, $pass, $dbname){
$this->host   = $host;
$this->user   = $user;
$this->pass   = $pass;
$this->dbname = $dbname;
 }

 function dbConnect(){
mysql_select_db ($this->dbname, $this->link);
 }


} // end multiConnect class

 

Then do the following to choose the different databases: -

 

$db = new multiConnect();

$db->getSingleton('localhost', 'username', 'password', 'databasename');

// Do stuff for databasename

$db->getSingleton('localhost', 'username2', 'password2', 'databasename2');

// Do stuff for databasename2

Posted

Hi, Thank you very much! I'll try this out later on!

 

I've got a semi idea of how to achieve what I want, I think I'll try to re-use the code from the admin/index.php or similar.

 

Thanks for taking the time to write that!

Kind regards

Chris

Posted

create four configre files in admin.

 

let admin select on login(from std db connected by default).

 

Now He selects the store and a proper configure.php file will connect to the store data and display.

 

YOu can do it by changing file name defines on store selection.

 

else Hobzilla contribution will help You out.

 

Satish

 

 

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Archived

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

×
×
  • Create New...