Topic on Extension talk:OdbcDatabase

Notice: Undefined index: odbc in D:\xampp\htdocs\SNWiki\includes\db\Database.php on line 915

3
Kghbln (talkcontribs)

I am Using MediaWiki 1.24


I Downloaded ExternalData and OdbcDatabase extensions for for getting sql server am adding these lines

require_once "$IP/extensions/OdbcDatabase/OdbcDatabase.php";

include_once "$IP/extensions/ExternalData/ExternalData.php";


$edgDBServerType ['mydb'] = "odbc";

$edgDBServer ['mydb'] = "my_dsn";
$edgDBName ['mydb'] = "UNUSED"; 

$edgDBUser ['mydb'] = "sa";

$edgDBPass ['mydb'] = "sa@123";
$edgDBTablePrefix ['mydb'] = "dbo";


and i created my_dsn odbc in my windows wiki server in wiki page

{{#get_db_data: db=mydb |from=Testtable |data=test1=test1,test2=test2}}

now submit the page i got a below error message on top of the page

Undefined index: odbc in D:\xampp\htdocs\SNWiki\includes\db\Database.php on line 915

In Database.php the line 915 is below bold line


if ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) {

$params = array(

'host' => isset( $p['host'] ) ? $p['host'] : false,

'user' => isset( $p['user'] ) ? $p['user'] : false,

'password' => isset( $p['password'] ) ? $p['password'] : false,

'dbname' => isset( $p['dbname'] ) ? $p['dbname'] : false,

'flags' => isset( $p['flags'] ) ? $p['flags'] : 0,

'tablePrefix' => isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global',

'schema' => isset( $p['schema'] ) ? $p['schema'] : $defaultSchemas[$dbType],

'foreign' => isset( $p['foreign'] ) ? $p['foreign'] : false

);


If i type wrong table name in wiki page it showing Below Errors

Notice: Undefined index: odbc in D:\xampp\htdocs\SNWiki\includes\db\Database.php on line 915

Warning: odbc_exec(): SQL error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'Testtable1'., SQL state S0002 in SQLExecDirect in D:\xampp\htdocs\SNWiki\extensions\OdbcDatabase\OdbcDatabase.body.php on line 26'

so i think connectivity is not a problem.

Kindly Help me

Chiefgeek157 (talkcontribs)

Ragu, great question. I have not yet tested on 1.24.x as we are stuck on 1.21. There may be a change in Database.php that adds additional logic around the $defaultSchemas array. I am sure the value 'odbc' does not appear in the $defaultSchemas array. Since OdbcDatabase builds on the ExternalData extension, there may be a dependency there I have not yet tested where we need to pass $p['schema'] in somehow. ExternalData may not yet support a config variable (e.g. $edgDBSchema) to support specifying the schema.

In the short term, you might be able to find where $defaultSchemas is defined and add a reasonable value for 'odbc'. A more elegant solution will require more time.

I am in the process of upgrading our MediaWiki to the current release (finally!), so may be able to update the OdbcDatabase extension in the near future.

Ragusathis (talkcontribs)

Thanks for your reply. now i am adding element in defaultschema for odbc in database.php

                       $defaultSchemas = array(
			'mysql' => null,
			'postgres' => null,
			'sqlite' => null,
			'oracle' => null,
			'mssql' => 'get from global',
                        'odbc' => null 

now data fetching is fine.

--Ragu

Reply to "Notice: Undefined index: odbc in D:\xampp\htdocs\SNWiki\includes\db\Database.php on line 915"