Re: [0.0] Re: [0.2] getting transactions to work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



i'm trying to test an idea. i know what i sent doesn't do much, but i try out ideas before i go too far to make sure i understand what i think i do in my 'real life' i work with oracle. i like the idea of explicitly telling the database when i'm done. i want to be able to trap errors and rollback if necessary. also to give someone the choice of saving the work or not. i know there are things i can do to create the similar effect,
create the sql, then when i'm ready submit it to the database.

i guess i'm trying to test the limits right now!

thanks for the input.

r

On 30 jul 2004, at 17.11, Rod K wrote:

You can find many resources to explain their purpose better than I can do here.

To be honest, I can't see what you are trying to accomplish in your script. If it's validation you should be using session variables to store the input AND echoing what was inputed on the validation page.

reiner peterke wrote:

this is meant in all honesty,

then whats the point?!

ok, let me put it this way. is there no way to implement pages using transactions?
otherwise it seems to kind of defeat the purpose of them.

r
On 30 jul 2004, at 16.57, Rod K wrote:

You are correct. You cannot have a transaction span multiple pages/scripts.

reiner peterke wrote:

there seems to be very little info around on actually using transactions with postgres. i've tried to create a page that will take input from a form and insert it into my database. it works if i just do it without transactions but when i try to use with the begin and commit sections of code, it doesn't update the data base. i'm guessing it is doing a rollback when my page loads itself again. can anyone help me out here ?

thanks

r

code below

<html>
<head>
<submitle>those eyes</submitle>
</head>
<body>
  <?
  $conn = pg_connect("dbname=entish user=postgres");
    if(!$conn)
    {
      print "not for the chocolate";
      exit;
    }
  if ($_POST[submit])  {

    $begin = pg_query("begin");
    $isql = "insert into diety(diety,culture,gender)
values ('$_POST[diety]','$_POST[culture]','$_POST[gender]')";
    printf("-- %s --\n",$isql);
    $results = pg_query($isql);
    ?>
    <form method="post" action="<? echo $PHP_SELF?>">
      <input type="Submit" name="action" value="commit">
      <input type="Submit" name="action" value="rollback">
    </form>
    <?
  }
  else if(!$_POST[action]) {
  ?>
    <form method="post" action="<? echo $PHP_SELF?>">
      Diety:<input type="text" name="diety"><br>
      Culture:<input type="text" name="culture"><br>
      Gender:<input type="text" name="gender"><br>
      <input type="Submit" name="submit" value="enter">
    </form>
    <?
  }
  else {
    if($_POST[action] == 'commit') {
      echo "let me see";
      $act = pg_query("commit");
    }
    else {
      $act = pg_query("rollback");
      }
  }  //end if $_POST[submit]
?>
</body>
</html>
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend






---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faqs/FAQ.html




[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux