<?php
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";
$query= "SELECT client_id, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id ";
$result = pg_query($conn,$query);
?>
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">
<style>
.responstable {
margin: 1em 0;
width: 100%;
overflow: hidden;
background: #FFF;
color: #024457;
border-radius: 10px;
border: 1px solid #167F92;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container-fluid">
<div>
<h1>Clients</h1>
</div>
<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
<tr>
<th>Client id</th>
<th>Insurance</th>
<th>Number of rows</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
?>
<tbody>
<td><?php echo $row['client_id']; ?></td>
<td><?php echo $row['insurance']; ?></td>
<td><?php echo $row['rows'];?></td>
</tr>
<?php }
?> </tbody>
</table>
</div>
</body>
</html>
전에서 내 출력을 위의 코드를 가지고 그것을 해결하는 방법을, 내가 추가를 시도그룹화 특정 행이 함께
Client id Number of rows Insurance
------------ ----------------------- --------------
123 3 rows AA,EE,U
125 2 rows AA,UE
126 1 rows CU
124 1 rows UE
임 확실하지 이 줄을 내 검색어에 입력 :
concat(count(*), ' rows') AS rows
ror, 행이 나오기 위해 내가 할 수있는 것에 대한 아이디어와 "{"와 ""가 간다?
나는 그것을 시도를, I 이 오류가 발생했습니다 : 경고 : pg_query() : 쿼리가 실패했습니다 : ERROR : concat (bigint, unknown) 함수가 존재하지 않습니다 LINE 1 : SELECT client_id, concat (count (*), 'rows') AS 행, array_agg ...^힌트 : 아니오 함수는 주어진 이름 및 인수 유형을 찾습니다. 명시 적 타입 캐스트를 추가해야 할 수도 있습니다. in index.php 8 행 –
또한 볼 수 있듯이 PostgreSQL을 사용하여 일반 SQL –
업데이트 된 대답을 확인 – Sundar