我从查询中获取值 我正在寻找这样的输出:
请帮助我如何做到这一点我试图获得这个
$cols = array ('test.title', 'test_stats.*' );
$select = $db->select () ->from ( 'test', $cols )
->join ( 'test_stats', 'test_stats.test_public_id = test.test_public_id', array ())
->where ( 'test_stats.updated_on > DATE_SUB(CURDATE(), INTERVAL 1 DAY)' )
->order ( 'title' );
$result = $db->fetchAll ( $select );
foreach ( $result as $row1 ) {
$title = $row1 ['title'];
$testPublicId = $row1 ['test_public_id'];
$views = count($testPublicId);
}
$select = $db->select ()
->from ( 'test_stats', array ('count(test_public_id) AS total_views' ))
->where ( 'test_public_id = ?', $publicId );
$result2 = $db->fetchAll ( $select );
foreach ( $result2 as $row2 ) {
$totalViews = $row2 ['total_views'];
$x= '<table>
<tr>
<td > ' . $title . ' </td>
<td > ' .$testPublicId . ' </td>
<td > ' . $views . ' </td>
<td > ' . $row1 ['addr'] . ' </td>
<td > ' . $totalViews . ' </td>
</tr>
</table>';
}
}
print_r($x);
答案 0 :(得分:0)
我不知道zend_db但是,这里是sql查询
SELECT column1,column2,column3,
GROUP_CONCAT(column_ip SEPARATOR ','),
column5
FROM table
GROUP BY column1,column2,column3,column5