2 счетчика в запросе

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
$count = $db->prepare("
select * from
(select count(id) from img where `mod` = '0' and block = '0' and category = :id and time = :time) as count1,
(select count(id) from img where `mod` = '0' and block = '0' and category = :id) as count2
");
$count = $count->execute(array(
':id' => $post['id'],
':time' => time()-86400
));
$count = $count->fetch(PDO::FETCH_OBJ);
# первый
echo $count->count1;
# второй
echo $count->count2;