<? $v_dbname = ""; //データベースの名前を変数へ代入 $v_user = ""; //ユーザー名を変数へ代入 $v_password = ""; //パスワードを変数へ代入 $tbl="adminlog"; //表示したいテーブルの名前 ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <title>テーブル内容</title> </head> <body> <div align="center"> <table width="350" border="0" bgcolor="#009999"> <tr> <td height="12"> <div align="center"><b><font color="#FFFFFF">テーブル内容</font></b></div> </td> </tr> </table> <br> <div align="center"> <b>テーブル名:<? print $tbl ?></b> <table width="510" border="0" cellspacing="2" cellpadding="2" align="center"> <tr bgcolor="#113333" height="20"> <td width="20"> <div align="center"><b><font color="#FFFFFF">Num</font></b></div> </td> <td width="120"> <div align="center"><b><font color="#FFFFFF">フィールド名</font></b></div> </td> <td width="120"> <div align="center"><b><font color="#FFFFFF">タイプ</font></b></div> </td> <td width="60"> <div align="center"><b><font color="#FFFFFF">ByVal</font></b></div> </td> <td width="80"> <div align="center"><b><font color="#FFFFFF">Not NULL</font></b></div> </td> <td width="110"> <div align="center"><b><font color="#FFFFFF">初期値設定</font></b></div> </td> </tr> <? // Connect to DB if (@pg_connect("dbname=$v_dbname user=$v_user password=$v_password") == false) { print("unable to connect to database."); exit; } pg_exec("SET CLIENT_ENCODING = 'SJIS'"); $sql = "select a.attnum,a.attname,t.typname ,a.atttypmod,a.attbyval,a.attnotnull,a.atthasdef from pg_class c, pg_attribute a,pg_type t " . "where a.attnum > 0 and a.attrelid=c.oid and a.atttypid=t.oid and c.relkind='r' and c.relpages=10 and c.relname='$tbl' " . "order by attnum;"; @$result = pg_exec($sql); if ($result == false) { printf("failed to exec SQL:¥"$sql¥""); exit; } $rows = pg_numrows($result); $iro = "99CCCC"; for ($i = 0; $i < $rows; $i++) { $attnum = pg_result($result, $i, "attnum"); $attname = pg_result($result, $i, "attname"); $typname = pg_result($result, $i, "typname"); $atttypmod = pg_result($result, $i, "atttypmod"); $attbyval = pg_result($result, $i, "attbyval"); $attnotnull = pg_result($result, $i, "attnotnull"); $atthasdef = pg_result($result, $i, "atthasdef"); if ($iro == "AACCCC") { $iro = "CCEEEE"; } else { $iro = "AACCCC"; } print ("<tr bgcolor=¥"#$iro¥" height=¥"26¥">"); print ("¥n"); print ("<td><div align=¥"right¥">$attnum</div></td>"); print ("¥n"); print ("<td>$attname</td>"); print ("¥n"); print ("<td>$typname"); if ($typname=="varchar") { print (" (".($atttypmod-4).")"); } print ("</td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($attbyval == "t" ? "Yes" : "")."</div></td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($attnotnull == "t" ? "Not NULL" : "")."</div></td>"); print ("¥n"); print ("<td><div align=¥"center¥">".($atthasdef == "t" ? "有" : "")."</div></td>"); print ("¥n"); print ("</tr>¥n"); } pg_close(); ?> </table> </div> </body> </html>
(Last Update 2002/07/05)