Kendinize göre düzenlersiniz.
require_once 'config.php';
$cek= $baglan ->prepare("SELECT * FROM logs WHERE ip_adresi='::1' and (sorgu='birinci' or sorgu='hepsi') order by id desc");
$cek->execute();
$veri = $cek->fetchAll(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($veri);
echo "</pre>";