2014-10-29 73 views
0

我有兩個模式,一個叫public,另一個叫SIEM。 我想從SIEM模式打印表格,但它不打印任何東西。 如何選擇我想要打印表格的模式?如何從Postgresql數據庫中選擇我想要的模式?

$query = "SELECT * from Maquina222"; 

$result = pg_query($conn,$query); 

$i = 0; 
echo '<html><body><table><tr>'; 
while ($i < pg_num_fields($result)) 
{ 
    $fieldName = pg_field_name($result, $i); 
    echo '<td>' . $fieldName . '</td>'; 
    $i = $i + 1; 
} 
echo '</tr>'; 

$i = 0; 

while ($row = pg_fetch_row($result)) 
{ 
    echo '<tr>'; 

    $count = count($row); 
    $y = 0; 
    while ($y < $count) 
    { 
     $c_row = current($row); 
     echo '<td>' . $c_row . '</td>'; 
     next($row); 
     $y = $y + 1; 
    } 
    echo '</tr>'; 
    $i = $i + 1; 
} 
pg_free_result($result); 

echo '</table></body></html>'; 

回答

1

您可以限定您的表(SIEM.Maquina222)的名稱或架構添加到您的路徑SET search_path = public,SIEM)。

編輯:

查看esp。 5.7.3. The Schema Search Path。您可能需要使用ALTER TABLEALTER ROLE

+0

當你說'添加模式到PATH時,你是什麼意思?你的意思是將SET search_path = public,SIEM添加到我的php代碼中? – 2014-10-29 21:23:24

相關問題