Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataObject specifing a connection name

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 407 Views
  • Alexw
    Community Member
    2 Posts

    DataObject specifing a connection name Link to this post


    I have a suggestion about the features of DataObjects. What about adding the ability to specify a connection name that a specific DataObject should need to use. There are situations that some tables are managed by Silverstripe but are located somewhere else or at different database name.


    $db = new MySQLDatabase(array(
          'server' => 'localhost',
          'username' => 'myUsername',
          'password' => 'myPassword',
          'database' => 'myDatabase'
    DB::setConn($db, 'external');


    class MyDataObject extends DataObject
       public static $conn = 'external';

       public static $db = array(
          'IsActive' => 'Boolean'

       public function getCMSFields()
          return new FieldList(
             new CheckboxField('IsActive')

    Kind regards,

  • martimiz
    Forum Moderator
    1091 Posts

    Re: DataObject specifing a connection name Link to this post


    Thanks for willing to contribute to SilverStripe! Propositions won't always be picked up from within these forums though. Please check out this documentation on how to contibute: http://doc.silverstripe.org/framework/en/trunk/misc/contributing/code

    In the mean time, as to multiple db connections, there are some solutions/workarounds around. For example: http://www.silverstripe.org/customising-the-cms/show/13692

    I remember a discussion about this a short while ago in the core developers group (https://groups.google.com/d/forum/silverstripe-dev) but I can't seem to find it just now...

    Basically afaik you cannot work with multiple connections at the same time, but you can switch between connections if need be.


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.