0

I need to customize a method on the DatabaseConnection_sqlsrv (MSSQL) driver, so i created a new driver class called DatabaseConnection_sqlsrvseed and extended all depended classes from the *_sqlsrv classes.

class DatabaseConnection_sqlsrvseed extends DatabaseConnection_sqlsrv {
  public function driver() {
    return 'sqlsrvseed';
  }
  public function databaseType() {
    return 'sqlsrvseed';
  }
}

Basically all other classes in the database/sqlsrvseed folder are empty classes that inherit their functionality from their parents like this one:

class InsertQuery_sqlsrvseed extends InsertQuery_sqlsrv {}

I am doing this because i need a modification on createFieldSql in DatabaseSchema_sqlsrv to create IDENTITY fields with a Seed value.

However, whenever i set

$database['default']['default']['driver'] = 'sqlsrvseed'

i get the error:

Fatal error: Class 'DatabaseConnection_sqlsrvseed' not found in C:[...]\includes\database\database.inc on line 1686

Although i am pretty sure that the class and all dependencies exist.
I did excactly everything like they did it in the sqlsrv driver:

Drupal and the SQL Server driver Uncompress Drupal in the web root. Uncompress this driver as sites/all/modules/sqlsrv, and copy or link the sqlsrv directory found inside it in includes/databases.

So I copied the files from database folder as well as the module folder. But there is a strange difference. I can't activate my custom driver module, whereas i can activate sqlsrv one. Any help? How does drupal gets to know this driver, without core modification?

3
  • Where have you put your classes? In .inc files properly mentioned in your .info?
    – Mołot
    Jul 1 '13 at 15:01
  • i put them in DRUPAL_ROOT . '/includes/database/sqlsrvseed/. Looking at line 1686 in database.inc the require_once of the file where DatabaseConnection_sqlsrvseed is defined works. But the initialization does not... Jul 1 '13 at 15:10
  • Problem is - by doing that you hacked core. Try to wrap them into a proper module and then use my answer.
    – Mołot
    Jul 1 '13 at 15:14
0

It looks like Drupal's autoload failed. For it to work you should put your classes in .inc file in your module, and then mention it in files line of module's .info file.

If that does not help and your classes are needed even earlier, include them in your settings.php:

require_once('path/to/module/sqlsrvseed.inc');
3
  • I did excactly everything like they did it in the sqlsrv driver and they follow the same approach. drupal.org/node/1207972: Drupal and the SQL Server driver Uncompress Drupal in the web root. Uncompress this driver as sites/all/modules/sqlsrv, and copy or link the sqlsrv directory found inside it in includes/databases. So I copied the files from database folder as well as the module folder. But there is a strange difference. I can't activate my custom driver module... Jul 1 '13 at 15:24
  • Oh, if your module is not enabled, it's no surprise it fails. But I think you should edit your question telling that, and explainning how you can't enable it. Error message? Checkbox just grayed?.. and so on
    – Mołot
    Jul 1 '13 at 15:28
  • checkbox grayed. I edited my question. But this drives me crazy... why is this that complicated and not even documented? Jul 1 '13 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.