1
I’m starting in the world of programming and at first I have a problem when I run the query locally the query shows me the return normally but when I try to query through a simple application:
<?php
/**
*
* @var string $dsn : driver de conexão : endereco do servidor : nome do banco
* @var string $user : usuario do banco
* @var string $pass : senha do usuario
*/
$dsn = 'odbc:driver={SQL Server};server=IP_DO_SERVIDOR;database=TESTE';
$user = 'xxxxxxx';
$pass = 'xxxxxxx';
try
{
$pdo = new PDO($dsn,$user,$pass);
}
catch(PDOException $exeption)
{
die("Erro: $exeption");
}
// Definindo o mode de erros da classe
//$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$select = "SELECT * FROM FIN_TITULO WHERE EMPRESA = 1 AND REVENDA = 1 AND TITULO = 435376";
$result = $pdo->exec($select);
var_dump($result);
the var_dump
returns the value 0, that is, no affected line, I do not know what to do, it would perhaps be the user’s permission because the direct query through SQL management works normally?
my problem is not related to connection but with query the return displayed in var_dump is still 'int(0)' should be 'int(1)'
– Guilherme Arantes
@Guillermos updated. Sorry for the confusion
– rbz
Opa worked, just did not understand why the result of my initial consultation had no return
– Guilherme Arantes
You can try to check like this:
$db->exec($select) or die(print_r($db->errorInfo(), true));
, dessa is will display the error for you to debug. You can also use the$db->query($select)
.– rbz