New Php Sql Server driver connection problem

Hey there,

I’m wondering if I am doing something wrong or maybe the framework need a small review on the CMssqlPdoAdapter.

Im running Yii locally on IIS7, PHP 5.3.10, latest sqlsrv driver (3.0 released this month, but I’ve tried even with the previous one) and connected to a DB located on Windows Azure and SQL Azure works as the classic Microsoft SQL Server does.

The weird fact is that Im able to connect succesfully but when it comes to ask for the schema and list tables I get empty results.




Yii::app()->db->getSchema()->tables;

Yii::app()->db->getSchema()->tableNames;



Both the mentioned commands returns empty arrays and if I try to load any CActiveRecord Framework says that it cant find the table.

This get more weird when I make a very simple sql query thourgh the CDbConnection component like the following one:




$command=Yii::app()->db->createCommand("SELECT * FROM test.app");

$command->execute();

$reader=$command->query();

foreach($reader as $row) {

	foreach($row as $key=>$value)

		echo $key.' '.$value.'</br>';

}



and I get all the data that was supposed to return, so I’m not sure if the problem is located inside my pdo or somewhere else. Does anybody ever encountered a similar

issue?


Here follows the connection string




'db'=>array(

		'connectionString' => 'sqlsrv:Server=tcp:xxxxxxxxx.database.windows.net;Database=test;',

      		'username' => 'username@xxxxxxxxx',

      		'password' => 'mypass',

}



and these is my driver configuration retrieved thourgh CDbConnection methods or properties:

driverName: sqlsrv

clientversionAttr: DriverDllName sqlncli11.dll

clientversionAttr: DriverODBCVer 03.80

clientversionAttr: DriverVer 11.00.2100

clientversionAttr: ExtensionVer 3.0.3313.0

pdoClass: PDO

pdoInstance: CMssqlPdoAdapter

connectionString: sqlsrv:Server=tcp:xxxxxxxxx.database.windows.net;Database=test;

CurrentDatabase: test

SQLServerVersion 11.00.1855

SQLServerName xxxxxxxxx

serverVersion: 11.00.1855

Thank you in advance

Giuliano

I’ve found out the problem.

When creating a new DB on SQL Azure you are forced to create a whole new db owner, meanwhile the CMsSqlPdoAdapter has a constant inside that makes it work only with the classic "dbo" owner. After changing it with my new one everything runs fine.

Regards!