-3
I’m making a connection with Firebird through a PHP class, using PDO, however it is occurring a very sinister error in which I got lost, watch the pages, index.php / connect.php and class.
INDEX.PHP
require("conectar.php");
$sql = "SELECT NOMCLI FROM SINAF019";
$stmt = $lokos->query($sql);
$stmt->execute();
$itens = $stmt->fetchAll(PDO::FETCH_ASSOC);
if($itens !== false)
{ foreach($itens as $row) {
echo "<span>".$row['NOMCLI']."</span>";
}
}
Connect.php
require("conectarDuosig.class.php");
$duo = new Duosig();
$duo->host = "127.0.0.1";
$duo->user = "SYSDBA";
$duo->pass = "masterkey";
$duo->dbnome = "127.0.0.1:DCOL";
$duo->conecta();
conectarDuosig.class.php
class Duosig{
// variaveis para a conexão
public $host;
public $user;
public $pass;
public $dbnome;
// função para conectar
function conecta(){
$lokos=new PDO("firebird:localhost=$this->host;dbname=$this->dbnome",$this->user, $this->pass);
}
}
When I do with the class it error on line 21 which in case is the
$stmt = $lokos->query($sql);
But when I make the connection pure, right into the source code
going there and putting
$lokos=new PDO("firebird:localhost=127.0.0.1;dbname=127.0.0.1:DCOL", $pass, $user);
and do the select, it pulls normal.
Could inform the error that occurs?
– Guilherme Nascimento
I noticed that you have several answers that solved your problem, but you did not mark any as "correct", I suggest you take the tour to understand how the site works http://answall.com/tour . The community thanks you.
– Guilherme Nascimento
How and why to accept an answer?
– Guilherme Nascimento
Please @Edwardjunior, register here: http://meta.pt.stackoverflow.com/q/4067/132
– Victor Stafusa