Thursday, 3 October 2013

PHP screen blank and heterogeneous query



Here’s what happened today, I tried to modify our internal system for a new report and the report created keep showing blank page (our reporting system is in PHP). Before the modification, this system already has 2 other types of connection, 1 to mySQL server of course since it uses PHP and the other one is Oracle.
What I was trying to do was, to connect to another database, this time MSSQL  server.
This first thing to do was to create a proper connection in the config file where all the other 2 connection were successfully created. This is what I set (only for MSSQL connection) in the config file
<?php
/* config for adodb */
include ("dir/adodb/adodb.inc.php");
require_once('dir/adodb/adodb-active-record.inc.php');
include_once('dir/adodb/toexport.inc.php');
define('ADODB_ASSOC_CASE', 2);
$myDBCon = NewADOConnection('mssql');
$myDBCon->Connect("yourserver", "userid","password", "DB Name");
ADOdb_Active_Record::SetDatabaseAdapter($myDBCon);
?>

But the screen keep showing this :
 
Found out that what happened actually was, the dll for the mssql was not loaded to the server, so after I uncommented the line in the php.ini, restarted the Apache .





The program started to work…but another error was prompted "Heteregeneous queries require the....."




Since my SQL actually is using a linked server (Oracle) from the mssql sever  (heterogeneous) there are 2 things need to be done first to allow the query to be pass.


So this is what I added to the previous setting in the config file.


<?php
/* config for adodb */
include ("dir/adodb/adodb.inc.php");
require_once('dir/adodb/adodb-active-record.inc.php');
include_once('dir/adodb/toexport.inc.php');
define('ADODB_ASSOC_CASE', 2);
$myDBCon = NewADOConnection('mssql');
$myDBCon->Connect("yourserver", "userid","password", "DB Name");
ADOdb_Active_Record::SetDatabaseAdapter($myDBCon);
/* add for heterogenous SQL */
$myDBCon->Execute("SET ANSI_NULLS ON ");
$myDBCon->Execute("SET ANSI_WARNINGS ON");
?>
 
And after that waalllaa….my precious data…finally.

 

No comments:

Post a Comment