I came across a sql error, but when I run the query in SQL Server Studio it returns the normal query. Query that is below.
SELECT
CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),' xmlns="http://www.portalfiscal.inf.br/nfe"','') as xml).value('(/nfeProc/NFe/infNFe/transp/vol/qVol/node())[1]', 'int') as [qVol]
FROM SPDNFE
WHERE CdIdNFe = 'NFe13161203976141000132550030000435291400513027'
Now when I transpose the same sql query into php it returns an error. As it is in php:
public function teste($nrchave) {
$sql = "SELECT
CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),' xmlns=\"http://www.portalfiscal.inf.br/nfe\"','') as xml).value('(/nfeProc/NFe/infNFe/transp/vol/qVol/node())[1]', 'int') as [qVol]
FROM SPDNFE
WHERE CdIdNFe = '$nrchave'";
$results = array();
$stmt = $this->conn->prepare($sql);
$stmt->execute();
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$info = new Model();
$info->setQVol($row->qVol);
$results[] = $info;
}
}
return $results;
}
Error:
Uncaught exception 'PDOException' with message 'SQLSTATE [42000]: [Microsoft] [ODBC Driver 11 for SQL Server] [SQL Server] SELECT failed because the following SET options have incorrect settings: 'ARITHABORT'. Verify that SET options are correct for use with indexed views and / or indexes on computed columns and / or filtered indexes and / or query notifications and / or XML data type methods and / or spatial index operations. '