Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

MySQL and MSSQL ORM in Same Module


Go to End


2 Posts   972 Views

Avatar
tazzydemon

Community Member, 135 Posts

19 May 2015 at 8:56am

On a Silverstripe instance running MySQL I need to create a module that talks to a read only remote MSSQL database table. All of the talk here is about connecting Silverstripe to MSSQL and that's not what I need to do.

My best guess is that I have to use whatever the best php connectors are to set up and talk to MSSQL manually and not use some sort of mixed ORM. Would I be right?

Avatar
Pyromanik

Community Member, 419 Posts

19 May 2015 at 9:28pm

Edited: 19/05/2015 10:08pm

Nah. Doable no matter the server (provided you have the correct adaptors installed - but MySQL is default, so should always work)

SQLQuery and DB::query() exist for more low level access, most likely what you're looking for.

If it's on the same server (and the user has permission) just fully qualify your queries.

If it's a separate server, open a new connection. Be careful about overriding the default connection though - be sure to name your connection.

$db = DB::getConn($name) ?: DB::connect($params, $name); //see API for more info
$db->query($sql);