ycast
(Mail2)
December 10, 2012, 8:40pm
1
Hi all,
I have a query to a MSSQL server that fails, but no error message is shown.
All other PHP errors are shown.
Does anyone know how I can display all mssql error messages? Or access the error message from my recent query?
I am using following connection string:
'connectionString' => 'dblib:host=0.0.0.1;dbname=mydb;charset=UTF-8',
Here is my code:
$connection = Yii::app()->db;
$sql = "
SELECT TOP 30
bz.Article_ID,
FROM
dbo.TableXYZ AS bz // Should show a error message, because TableXYZ is not there.
";
$command = $connection->createCommand($sql);
$connection->errorInfo();
$rows = $command->queryAll();
Regards
ycast
konapaz
(Konapaz)
December 11, 2012, 10:11am
2
check if connection string is ok
http://www.yiiframework.com/wiki/192/config-use-ms-sql-server-2005-2008/
also check the logs file in protected/runtime folder
ycast
(Mail2)
December 11, 2012, 11:02am
3
Thanks KonApaz, my connection string is fine. And my log files only show php errors…
If I change dbo.TableXYZ to a table that exists, results show as expected. Just no error messages when my sql is wrong.
konapaz
(Konapaz)
December 11, 2012, 12:32pm
4
ycast:
Thanks KonApaz, my connection string is fine. And my log files only show php errors…
If I change dbo.TableXYZ to a table that exists, results show as expected. Just no error messages when my sql is wrong.
Did you modify an confuguration file of Yii (or sqlserver) ?
In my case the mysql errors displayed.
$connection = Yii::app()->db;
$sql = "SELECT TOP 30 bz.Article_ID FROM dbo.TableXYZ AS bz TableXYZ";
$command = $connection->createCommand($sql);
$rows = $command->queryAll();
check with a tested mysql database if the errors displayed and let me know
ycast
(Mail2)
December 11, 2012, 7:47pm
5
MySQL errors are shown. So I guess it’s likely the configuration of the MSSQL server. Any thoughts where I could start looking?
konapaz
(Konapaz)
December 12, 2012, 12:30pm
6
which version of Yii you have?
also check the version of sql server
also check
‘db’=>array(
'connectionString' => 'dblib:host=0.0.0.1;dbname=mydb;charset=UTF-8',
'emulatePrepare' => [color="#FF0000"]false, OR true OR remove this line entirely[/color]
'username' => '...',
'password' => '...',
'charset' => 'utf8',
),
finaly make your own php code to check if the problem exist on PDO php or your sqlserver
http://msdn.microsoft.com/en-us/library/ff628154(v=sql.105).aspx