How can I get the number of records in mySQL DB via PDO?.
My codes: (But something is wrong.It is not working.)
function AlandakiDegerlerToplami ($tablo,$alan)
{
$dsn = 'mysql:host='.$host.';dbname='.$veritabaniadi;
try {
$this->conn = new PDO($dsn, $kullaniciadi, $sifre);
} catch (PDOException $e) {
echo vthatasi .':'. $e->getMessage();
}
$veriler = $this->conn->prepare('SELECT sum('.$alan.') as adet from '.$tablo);
$toplam=$veriler->execute();
return $toplam['adet'];
}
function TablodakiKayitSayisi ($tablo)
{
$dsn = 'mysql:host='.$host.';dbname='.$veritabaniadi;
try {
$this->conn = new PDO($dsn, $kullaniciadi, $sifre);
} catch (PDOException $e) {
echo vthatasi .':'. $e->getMessage();
}
$veriler = $this->conn->prepare('SELECT count(*) as adet from '.$tablo);
$toplam=$veriler->execute();
return $toplam['adet'];
}
}