Yii Framework Forum: Multiple Databases with the same Model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multiple Databases with the same Model Rate Topic: -----

#1 User is offline   Rotlaus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 03-March 10

Posted 03 March 2010 - 04:25 AM

For a new application we are looking for a php web framework that supports multiple databases with the same schema/model. Every customer of us will become his own webserver with his own database. On top of this we want to develop a central administration app that works on all customer databases, which are all have the same schema/model. Does Yii support such a thing? If not, would it be easy to add this to the current Database/Active Record functionality?
0

#2 User is offline   jerry2801 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 504
  • Joined: 18-November 09

Posted 03 March 2010 - 05:21 AM

you can add function in your model like:

public function getDbConnection()
{
    return Yii::app()->user->getState('myDbConnectionId');
}

0

#3 User is offline   riccardo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 02-March 10

Posted 03 March 2010 - 10:40 AM

But how can i set myDbConnectionId dynamically so that every time i can specify the db to be used?

View Postjerry2801, on 03 March 2010 - 05:21 AM, said:

you can add function in your model like:

public function getDbConnection()
{
    return Yii::app()->user->getState('myDbConnectionId');
}


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users