17 include_once(
'Class.Application.php');
23 include_once(
"$pubdir/$appclass/Class.$class.php");
29 print _(
"cannot access to database $db\n");
31 }
else print _(
"access granted to database $db\n");
34 $rq=@pg_query (
$dbid,
"select * from ".
$o->dbtable.
" LIMIT 1;");
46 if (pg_result_error(
$rq) ==
"") {
47 if (pg_num_rows(
$rq) > 0 ) {
48 $row= pg_fetch_array(
$rq,0,PGSQL_ASSOC);
50 $fieds = array_intersect(
$o->fields,array_keys($row));
51 $sql[]=
"CREATE TABLE ".$o->dbtable.
"_old AS SELECT * FROM ".
$o->dbtable.
";";
54 $sql[]=
"DROP TABLE ".$o->dbtable.
";";
57 while (list($k,$sqlquery)=each(
$sqlcmds)) {
58 if (chop($sqlquery) !=
"")
63 $sql[]=
"INSERT INTO ".$o->dbtable.
" (".implode(
",", $fieds).
") SELECT ".implode(
",", $fieds).
" FROM ".$o->dbtable.
"_old";
65 $sql[]=
"DROP TABLE ".$o->dbtable.
"_old;";
68 while (list($k,$v) = each (
$sql)) {
72 if (preg_match(
"/create sequence/",$v, $reg)) {
73 $pgmess = pg_errormessage(
$dbid);
74 echo
"[1;33;49m".$pgmess.
"[0m\n";
77 $pgmess = pg_errormessage(
$dbid);
78 echo
"[1;31;49m".$pgmess.
"[0m\n";
79 echo
"[1;31;40m".
"ABORTED".
"[0m\n";