SQL Server Code for Drupal 5 Released

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
pcorbett's picture

I've uploaded my code for a MSSQL-compatible Drupal 5 installation. The only folder that didn't commit properly was modules/color, so I'll try to get that working soon - hopefullly that doesn't prevent you from installing and using a non-color module theme. You can find the files on cvs.drupal.org at /contributions/sandbox/pcorbett/drupal-mssql. You'll need to checkout all the folders and then move the contents of the root_folder_files into your root folder (CVS doesn't let me commit files that aren't contained in a folder).

If you need help getting started, let me know. This may or may not be helpful to anyone - I'm using this in a production environment, but with some 3rd party apps such as FreeTDS to talk between PHP and SQL Server using phpdblib.dll instead of the typical php_mssql.dll (which poses some restrictions on DB calls made from PHP and making it difficult to use Drupal).

There are some php.ini settings that may not be obvious, so if you have issues, feel free to contact me.

Hopefully we'll have D6 ready for SQL Server shortly. I've heard rumors that others are already working on this and there are some new developments that should make using FreeTDS unnecessary.

So, if there are still D5 users out there dying to run it on SQL Server, here you go, enjoy!

Comments

good timing

Chris Charlton's picture

I am interested in this option.

I saw how you can swap databases in settings.php files and a new db connection layer would be great, especially to pull away from (or compliment) .NET content management systems.

Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant

I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us

link?

Chris Charlton's picture

Where's the link to download or view code?

Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant

I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us

Checkout from CVS

pcorbett's picture

It's all on my sandbox: http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/pcorbett/dr...

Best way is to checkout from CVS, here's how: http://drupal.org/node/321

Feel free to contact me directly if you need specific help.

Drupal 7!

RobLoach's picture

Get this into Drupal 7! SQLite support was added last week, so I don't see why MSSQL support couldn't be added. Do it! The MS SQL Server PDO support is experimental, but it does work.

Will do

pcorbett's picture

I know, I've been so caught up in getting D5 going, practically two versions of Drupal have passed me by. I'll try to get this committed ASAP.

Hello boys :) Can U upload

toptyg's picture

Hello boys :)

Can U upload php source to other place... then http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/pcorbett/dr...

no so easy to download :( //maybe like rapidshare

Big thenx.

Install fails on existing MSSQL Database

hpcalaf's picture

You pointed me to your work in the Feature Request Category. I've installed your 5.x sandbox version but it doesn't complete the process. Can I get some advice about it please?

After supplying the correct credentials though (I have confirmed that I can access the database using OBDC and SQLExpress Client) the script returns to the initial entry point without response or error. I have the MSSQL driver installed for PHP and that it is loaded is confirmed by phpinfo(). Getting this to work will provide helpful information for me. I would appreciate any thoughts or troubleshooting tips to help figure out what might be going wrong.

Thanks much for any advice!

Details please

pcorbett's picture

Could you be more specific about how it doesn't complete the installation process? Does it end on a white-screen? Any error messages?

Also make sure you have the FreeTDS php_dblib.dll driver installed in your PHP extensions directory and have the config file set up properly. Please contact me directly if you think that will be more productive... I'm happy to help.

Drupal 6 and SQL Server

autome's picture

"Hopefully we'll have D6 ready for SQL Server shortly"

Any further news / development on SQL Server for D6?

Thanks.

installing drupal 6.2 and mssql

etothex23's picture

Could you helpme with an install of drupal 6.2 and mssql
I have the mssql drivers for php and they are working.
I do not know how to get Drupal to look for mssql
On the database configuration screen of drupal 6.2 install what do i do?
do i modify settings.php or a file in includes/ ?

i think it can't

drupalsmutant's picture

im never read or meet to install drupal in mssql

got it

etothex23's picture

I found the code to connect. Its up and running. If anyone needs it I can send the info.

Please post code

sjdavis's picture

Please post the connection code / setting. someone else in the community may be looking for help as you were any would really appreciate it.

Instructions

etothex23's picture

Configuring Drupal 6.2 to work with MS SQL Server

Using the code from:
https://code.launchpad.net/~drupal-sql-server/pressflow/drupal-sql-serve...

My current system configuration:
1. Windows XP Service pack 3
2. Apache/2.2.16 (Win32) PHP/5.3.5 – installed from the zip files not using an installer, PHP was thread safe VC6 x86
3. SQL Server Express 2008
4. Drupal 6.2 core

I had already had Apache and PHP running and configured. We were checking out Drupal 6 to use as our CMS and we have support for MS SQL Server and had to see if we could use the two together.

I went through the basic Drupal set up, copied the Drupal files into a folder under the web root. I set up a database on SQL Server, created a user for it. I made the user authenticate against SQL Server, and set it as the default database then copied and renamed default.settings.php to settings.php. The rest of the steps are where I had to do some modifications.

I searched around quite a bit and perhaps I missed the easy install steps but I just did not see them so I found the URL above and used that to create a few files and modify a few.

In /includes I did the following;
1. Created: install.sqlsrv.inc – used the code from the link to make this file.
2. Created: database.sqlsrv.inc – used the code from the link to make the file.
3. Edited – all from the link:
a. Menu.inc
b. Install.inc
c. Bootstrap.inc

Once I had these files in place I started the install as usual, going to the install.php in /drupal6 (or the directory you placed the files in.). This is the point where I had my only issue. During this process at the beginning I received an error stating:
“You cannot cannot declare db_distinct_field() twice”. I looked for the duplicates and found:

In database.sqlsrv.inc @ line 554 (could vary):
//changed 02/17/2011
/**
* Wraps the given table.field entry with a DISTINCT(). The wrapper is added to
* the SELECT list entry of the given query and the resulting query is returned.
* This function only applies the wrapper if a DISTINCT doesn't already exist in
* the query.
*
* @param $table Table containing the field to set as DISTINCT
* @param $field Field to set as DISTINCT
* @param $query Query to apply the wrapper to
* @return SQL query with the DISTINCT wrapper surrounding the given table.field.

function db_distinct_field($table, $field, $query) {
$field_to_select = "DISTINCT ON ($table.$field) $table.$field";
// (?<!foo) is to avoid rewriting queries that already use DISTINCT
$query = preg_replace(
"/(SELECT.)(?:$table.|\s)(?<!DISTINCT()(?<!DISTINCT($table.)$field(.FROM )/AUsi",
'\1 '. $field_to_select .'\2',
$query
);
return $query;
}

In database.inc @ line 391 (could vary)
/**
* Adds the DISTINCT flag to the supplied query and returns the altered query.
*
* The supplied query should not contain a DISTINCT flag. This will not, and
* never did guarantee that you will obtain distinct values of $table.$field.
*
* @param $table
* Unused. Kept to retain API compatibility.
* @param $field
* Unused. Kept to retain API compatibility.
* @param $query
* Query to which the DISTINCT flag should be applied.
*
* @return
* SQL query with the DISTINCT flag set.
/
function db_distinct_field($table, $field, $query) {
$matches = array();
if (!preg_match('/^SELECT\s
DISTINCT/i', $query, $matches)) {
// Only add distinct to the outer SELECT to avoid messing up subqueries.
$query = preg_replace('/^SELECT/i', 'SELECT DISTINCT', $query);
}

return $query;
}

I commented out the function in the database.sqlsrv.inc. I did not have any problems with the rest of the install.
I also set up mod_rewrite for clean URL’s. I used the httpd.conf file in Apache and not the .htaccess file.

Uncomment: LoadModule rewrite_module modules/mod_rewrite.so

Add:

added: 02/17/2011

Various rewrite rules.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

notice the line below I have my drupal6 installed in the drupal6 directory.

RewriteRule ^(.*)$ /drupal6/index.php?q=$1 [L,QSA]

You must have this after some of the other directives in the conf, so if you get http errors move it under any server/directory information in the file. You can find the rewrite rules on the Drupal site.