[Firebug-cvs] firebug/web/postgres connect.php,1.2,1.3 db_create.php,1.2,1.3 db_drop.php,1.1,1.2 db_
Brought to you by:
doolin
Update of /cvsroot/firebug/firebug/web/postgres In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32317 Modified Files: connect.php db_create.php db_drop.php db_dropdb.php db_list_databases.php db_select.php db_table_buttons.php db_table_select.php Log Message: Updated the error handling for the postgres version of the firebug database. Index: connect.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/connect.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** connect.php 19 Aug 2004 17:37:04 -0000 1.2 --- connect.php 19 Aug 2004 21:59:56 -0000 1.3 *************** *** 8,12 **** $connstr = "dbname=$db user=postgres host=localhost port=5432"; if(!($dbh = @pg_connect($connstr))) { ! die("Error: could not connect"); } return $dbh; --- 8,12 ---- $connstr = "dbname=$db user=postgres host=localhost port=5432"; if(!($dbh = @pg_connect($connstr))) { ! die("<strong>ERROR</strong>: Could not connect"); } return $dbh; Index: db_dropdb.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_dropdb.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_dropdb.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_dropdb.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 16,20 **** <?php $dbname = $HTTP_POST_VARS["db1"]; - print $dbname; ?> <hr /> --- 16,19 ---- *************** *** 25,29 **** $stat = @pg_exec($dbh,$statement); if (!$stat) { ! print "Error: Could not drop database $dbname"; } else { print "Database <strong>$dbname</strong> dropped."; --- 24,28 ---- $stat = @pg_exec($dbh,$statement); if (!$stat) { ! print "<strong>ERROR</strong>: Could not drop database <strong>".strtoupper($dbname)."</strong>."; } else { print "Database <strong>$dbname</strong> dropped."; Index: db_create.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_create.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** db_create.php 19 Aug 2004 17:37:04 -0000 1.2 --- db_create.php 19 Aug 2004 21:59:57 -0000 1.3 *************** *** 35,39 **** if (!$conn_stat) { ! print "Error: Could not check to see if database exists."; } else { --- 35,40 ---- if (!$conn_stat) { ! print "<strong>ERROR</strong>: Could not check to see if database <strong>".strtoupper($dbname)."</strong> exists."; ! pg_close($dbh); } else { *************** *** 46,50 **** } } ! /* Creates the database if it does not exist yet.*/ if (!$flag) { --- 47,51 ---- } } ! pg_close($dbh); /* Creates the database if it does not exist yet.*/ if (!$flag) { *************** *** 53,57 **** $create_stat = @pg_exec($dbh,$statement); if (!$create_stat) { ! print "Error: Could not create database $dbname."; pg_close($dbh); } else { --- 54,58 ---- $create_stat = @pg_exec($dbh,$statement); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not create database <strong>".strtoupper($dbname)."</strong>."; pg_close($dbh); } else { *************** *** 84,88 **** $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "Error: Could not create table LOCATION."; } --- 85,89 ---- $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not create table </strong>LOCATION</strong>."; } *************** *** 90,95 **** //$statement .= "lat_dec_min FLOAT, long_deg SMALLINT, long_dec_min FLOAT, nsew SMALLINT, numsats SMALLINT)"; - //mysql_query($statement) or die("Error: ".mysql_error()." in creating location atable"); - /* typedef struct Firedata_msg { --- 91,94 ---- *************** *** 106,110 **** $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "Error: Could not create table CURRENT."; $current_flag=1; } --- 105,109 ---- $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not create table <strong>CURRENT</strong>."; $current_flag=1; } *************** *** 116,120 **** $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "Error: Could not create table CUMULATIVE."; } --- 115,119 ---- $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not create table <strong>CUMULATIVE</strong>."; } *************** *** 125,129 **** $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "Error: Could not create table RANGE."; } --- 124,128 ---- $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not create table <strong>RANGE</strong>."; } *************** *** 143,147 **** $create_stat = @pg_exec($dbh, $statement); if (!$create_stat) { ! print "Error: Could not INSERT INTO CURRENT (mote_id) VALUES ($i)"; } else { print $statement; --- 142,146 ---- $create_stat = @pg_exec($dbh, $statement); if (!$create_stat) { ! print "<strong>ERROR</strong>: Could not INSERT INTO <strong>CURRENT</strong> (mote_id) VALUES ($i)"; } else { print $statement; *************** *** 158,162 **** print "<br />"; print("<a href=\"db_admin.php\">Create Another Database</a>"); - pg_close($dbh); } } --- 157,160 ---- Index: db_table_buttons.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_table_buttons.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_table_buttons.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_table_buttons.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 12,24 **** $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; ! $stat = pg_exec($dbh,$statement); ! $rows = pg_numrows($stat); ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<input type=hidden name=db1 value=\"$dbname\">"); ! print ("<input type=submit name=tbl1 value=\"" . $data[0] . "\">"); } ?> --- 12,30 ---- $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; ! $stat = @pg_exec($dbh,$statement); ! if (!$stat) { ! print "<strong>ERROR</strong>: Could not access list of tables for database <strong>".strtoupper($dbname)."</strong>."; ! } else { ! $rows = pg_numrows($stat); ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<input type=hidden name=db1 value=\"$dbname\">"); ! print ("<input type=submit name=tbl1 value=\"" . $data[0] . "\">"); ! } } + pg_close($dbh); + ?> Index: db_list_databases.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_list_databases.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_list_databases.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_list_databases.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 9,27 **** $dbh = connect_postgres("template1"); $statement = "SELECT DATNAME FROM pg_database where not datname='template1' and not datname='template0'"; ! $stat = pg_exec($dbh,$statement); ! $rows = pg_numrows($stat); ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<tr><td>"); ! print $data[0]; ! print ("</td>"); ! ! print ("<td>"); ! print ("<input type=radio name=db1 value=\"$data[0]\">"); ! print ("</td>"); ! ! print ("</tr>"); } ?> --- 9,32 ---- $dbh = connect_postgres("template1"); $statement = "SELECT DATNAME FROM pg_database where not datname='template1' and not datname='template0'"; ! $stat = @pg_exec($dbh,$statement); ! if (!stat) { ! print "<strong>ERROR</strong>: Could not access list of existing databases."; ! } else { ! $rows = pg_numrows($stat); ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<tr><td>"); ! print $data[0]; ! print ("</td>"); ! ! print ("<td>"); ! print ("<input type=radio name=db1 value=\"$data[0]\">"); ! print ("</td>"); ! ! print ("</tr>"); ! } } + pg_close($dbh); ?> Index: db_drop.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_drop.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_drop.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_drop.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 40,51 **** $dbh = connect_postgres("template1"); $statement = "SELECT DATNAME FROM pg_database where not datname='template1' and not datname='template0'"; ! $stat = pg_exec($dbh,$statement); ! $rows = pg_numrows($stat); ! ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print_dbname_row($data[0]); } ! ?> --- 40,55 ---- $dbh = connect_postgres("template1"); $statement = "SELECT DATNAME FROM pg_database where not datname='template1' and not datname='template0'"; ! $stat = @pg_exec($dbh,$statement); ! if (!$stat) { ! print "<strong>ERROR</strong>: Could not access list of databases."; ! } else { ! $rows = pg_numrows($stat); ! ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print_dbname_row($data[0]); ! } } ! pg_close($dbh); ?> Index: db_select.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_select.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_select.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_select.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 23,48 **** $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; ! $stat = pg_exec($dbh,$statement); ! $rows = pg_numrows($stat); ! ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<tr>"); ! ! print ("<td>"); ! print $data[0]; ! print ("</td>"); ! ! print ("<td>"); ! print ("<input type=radio name=tbl1 value=\"" . htmlspecialchars($data[0]) . "\">"); ! print ("</td>"); ! print ("</tr>"); ! } ! ! print ("</table>"); ! print ("<input type=hidden name=db1 value=\"$dbname\">"); ! print ("<input type=submit value=SUBMIT>"); pg_close($dbh); --- 23,51 ---- $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; ! $stat = @pg_exec($dbh,$statement); ! if (!$stat) { ! print "<strong>ERROR</strong>: Could not access list of tables for database <strong>".strtoupper($dbname)."</strong>."; ! } else { ! $rows = pg_numrows($stat); ! for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i); ! print ("<tr>"); ! ! print ("<td>"); ! print $data[0]; ! print ("</td>"); ! ! print ("<td>"); ! print ("<input type=radio name=tbl1 value=\"" . htmlspecialchars($data[0]) . "\">"); ! print ("</td>"); ! ! print ("</tr>"); ! } + print ("</table>"); + print ("<input type=hidden name=db1 value=\"$dbname\">"); + print ("<input type=submit value=SUBMIT>"); + } pg_close($dbh); *************** *** 55,64 **** <br /> - <!-- - Add links to go back to the firebug home page running on the - current server, and to the database admin page running on the - current server. - --> - <hr /> --- 58,61 ---- Index: db_table_select.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_table_select.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_table_select.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_table_select.php 19 Aug 2004 21:59:57 -0000 1.2 *************** *** 54,78 **** <?php $dbh = connect_postgres($dbname); ! $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname = 'current' and a.attrelid = c.oid and a.attnum > 0"; ! $stat = pg_exec($dbh,$statement); // Build the table header column names. Make this into a function. ! print("<tr>\n"); ! $cols = pg_numrows($stat); ! for ($i=0 ; $i < $cols; $i++) { ! print ("<td>"); ! $header = pg_fetch_row($stat,$i); ! print $header[0]; ! print ("</td>"); ! } ! print("</tr>\n"); ! $statement = "SELECT * FROM $tblname"; ! $stat = pg_exec($dbh,$statement); //Print the value for a row. function print_row($item2,$key) { ! print ("<td>\n"); echo "$item2\n"; --- 54,85 ---- <?php $dbh = connect_postgres($dbname); ! $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname = '$tblname' and a.attrelid = c.oid and a.attnum > 0"; ! $stat = @pg_exec($dbh,$statement); ! if (!$stat) { ! print "<strong>ERROR</strong>: Could not retrieve table header column names for<strong>".strtoupper($tblname)."</strong>."; ! } else { // Build the table header column names. Make this into a function. ! print("<tr>\n"); ! $cols = pg_numrows($stat); ! for ($i=0 ; $i < $cols; $i++) { ! print ("<td>"); ! $header = pg_fetch_row($stat,$i); ! print $header[0]; ! print ("</td>"); ! } ! print("</tr>\n"); ! ! $statement = "SELECT * FROM $tblname"; ! $stat = @pg_exec($dbh,$statement); ! if (!$stat) { ! print "<strong>ERROR</strong>: Could not access table <strong>".strtoupper($tblname)."</strong>."; ! } else { //Print the value for a row. function print_row($item2,$key) { ! print ("<td>\n"); echo "$item2\n"; *************** *** 82,96 **** //Print every row. ! $rows = pg_numrows($stat); // for each row ! for ($i=0;$i<$rows;$i++) { ! print ("<tr>"); // For each column... ! $row = array_values(pg_fetch_row($stat,$i)); ! array_walk($row,'print_row'); ! print("</tr>"); } - ?> --- 89,105 ---- //Print every row. ! $rows = pg_numrows($stat); // for each row ! for ($i=0;$i<$rows;$i++) { ! print ("<tr>"); // For each column... ! $row = array_values(pg_fetch_row($stat,$i)); ! array_walk($row,'print_row'); ! print("</tr>"); ! } ! } ! pg_close($dbh); } ?> |