I am connecting to an SQL Server database (SQL Server 2008 R2 SP2 x64) from a Linux server running PHP 5.3.19 using the following lines:
$this->dbLink = new PDO(
'dblib:host='.$this->host.';dbname='.$this->database,
$this->user,
$this->password,
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
)
);
The connection works perfectly fine, except that ATTR_ERRMODE works as ERRMODE_WARNING, no matter what I do.
I have tried setting it using $this->dbLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
right before the query call, but it has no effect.
If I use getAttribute()
, I can confirm that PDO::ATTR_ERRMODE is indeed set to int(2)
(ERRMODE_EXCEPTION), but I still get warnings and PHP keeps chugging along with obviously wrong queries.
try{}catch(){}
method to handle the exceptions, otherwise I can't tell what the problem might be. What do you get when you pass invalid query, what does the error say? – samayo