incubator-olio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject svn commit: r734327 - in /incubator/olio/webapp/php/trunk: classes/ public_html/
Date Wed, 14 Jan 2009 04:54:19 GMT
Author: akara
Date: Tue Jan 13 20:54:18 2009
New Revision: 734327

URL: http://svn.apache.org/viewvc?rev=734327&view=rev
Log:
Fix for issue OLIO-31: Implemented demarcation methods beginTransaction, commit, and rollback
for the connections and have the pages that write to the DB call the demarcation methods.

Modified:
    incubator/olio/webapp/php/trunk/classes/DBConnection.php
    incubator/olio/webapp/php/trunk/classes/ODBCConnection.php
    incubator/olio/webapp/php/trunk/classes/PDOConnection.php
    incubator/olio/webapp/php/trunk/public_html/addAttendee.php
    incubator/olio/webapp/php/trunk/public_html/addEventResult.php
    incubator/olio/webapp/php/trunk/public_html/addPersonResult.php
    incubator/olio/webapp/php/trunk/public_html/approveFriendship.php
    incubator/olio/webapp/php/trunk/public_html/deleteAttendee.php
    incubator/olio/webapp/php/trunk/public_html/deleteCommentsRating.php
    incubator/olio/webapp/php/trunk/public_html/events.php
    incubator/olio/webapp/php/trunk/public_html/friends.php
    incubator/olio/webapp/php/trunk/public_html/rejectInvite.php
    incubator/olio/webapp/php/trunk/public_html/revokeInvite.php

Modified: incubator/olio/webapp/php/trunk/classes/DBConnection.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/DBConnection.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/DBConnection.php (original)
+++ incubator/olio/webapp/php/trunk/classes/DBConnection.php Tue Jan 13 20:54:18 2009
@@ -53,5 +53,11 @@
     abstract function query();
     
     abstract function exec();
+
+    abstract function beginTransaction();
+
+    abstract function commit();
+
+    abstract function rollback();
 }
 ?>
\ No newline at end of file

Modified: incubator/olio/webapp/php/trunk/classes/ODBCConnection.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/ODBCConnection.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/ODBCConnection.php (original)
+++ incubator/olio/webapp/php/trunk/classes/ODBCConnection.php Tue Jan 13 20:54:18 2009
@@ -81,6 +81,21 @@
             return odbc_exec($this->connection, $sql);
         }
     }
+
+    function beginTransaction() {
+        $this->ensureConnection();
+        odbc_autocommit($this->connection, false);
+    }
+
+    function commit() {
+        odbc_commit($this->conneection);
+        odbc_autocommit($this->connection, true);
+    }
+
+    function rollback() {
+        odbc_rollback($this->connection);
+        odbc_autocommit($this->connection, true);
+    }
     
     function __destruct() {
         if (is_resource($this->connection)) {

Modified: incubator/olio/webapp/php/trunk/classes/PDOConnection.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/PDOConnection.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/PDOConnection.php (original)
+++ incubator/olio/webapp/php/trunk/classes/PDOConnection.php Tue Jan 13 20:54:18 2009
@@ -77,6 +77,23 @@
             return $this->connection->exec($sql);
         }
     }
+
+    function beginTransaction() {
+        $this->ensureConnection();
+        $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
+        $this->connection->beginTransaction();
+    }
+
+    function commit() {
+        $this->connection->commit();
+        $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true);
+    }
+
+    function rollback() {
+        $this->connection->rollBack();
+        $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true);
+    }
+
     
     function __destruct() {
         if (isset($this->connection)) {

Modified: incubator/olio/webapp/php/trunk/public_html/addAttendee.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/addAttendee.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/addAttendee.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/addAttendee.php Tue Jan 13 20:54:18 2009
@@ -25,8 +25,11 @@
 require_once("../etc/config.php");
 $se = $_REQUEST['id'];
 $username = $_SESSION["uname"];
+$txBegun = false;
 if (!is_null($username)) {
     $connection = DBConnection::getWriteInstance();
+    $connection->beginTransaction();
+    $txBegun = true;
     $checkuserIfAttending = "select count(username) as count from PERSON_SOCIALEVENT where
socialeventid = '$se' and username = '$username'";
     $result = $connection->query($checkuserIfAttending);
     $row = $result->getArray();
@@ -47,8 +50,13 @@
         $tmp_uname = $listqueryresult->get(1);
         $attendeeList = $attendeeList." ".'<a href="users.php?username='.$tmp_uname.'">'.$tmp_uname.'</a><br
/>';
 }
+
+unset($listqueryresult);
+if ($txBegun) {
+    $connection->commit();
+}
+
 $numofattendees = $_SESSION["numofattendees"] + 1;
 $_SESSION["numofattendees"] = $numofattendees;
 echo '<h2 class="smaller_heading">'.$numofattendees.' Attendees:</h2><br/><input
name="unattend" type="button" value="Unattend" onclick="deleteAttendee();"/><br/><div
id="attendees">'.$attendeeList.'</div>';
-unset($listqueryresult);
 ?>

Modified: incubator/olio/webapp/php/trunk/public_html/addEventResult.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/addEventResult.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/addEventResult.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/addEventResult.php Tue Jan 13 20:54:18 2009
@@ -56,6 +56,7 @@
 	$insertaddr = "insert into ADDRESS (street1, street2, city, state, zip, country, latitude,
longitude) ".
                       "values ('$strt1', '$street2', '$cty', '$state', '$zip', '$country',
".
                       "'$geocode->latitude', '$geocode->longitude')";
+    $connection->beginTransaction();
 	$connection->exec($insertaddr);
 	$cq = "select last_insert_id()";
 	$idres = $connection->query($cq);
@@ -241,6 +242,7 @@
         	$insertPS = "insert into PERSON_SOCIALEVENT values('$usrnm','$eventid')";
                 $connection->exec($insertPS);
         }
+$connection->commit();
         
 if (isset($_POST['addeventsubmit'])) {
         header("Location:events.php?socialEventID=".$eventid);

Modified: incubator/olio/webapp/php/trunk/public_html/addPersonResult.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/addPersonResult.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/addPersonResult.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/addPersonResult.php Tue Jan 13 20:54:18 2009
@@ -19,6 +19,7 @@
         
 require_once("../etc/config.php");
 $connection = DBConnection::getWriteInstance();
+$connection->beginTransaction();
 
 if(isset($_POST['addpersonsubmit'])) {
 	//insert into person table using the data from addPerson page
@@ -157,5 +158,7 @@
 	$connection->exec($updatesql);
 
 }
+
+$connection->commit();
 header("Location:users.php?username=".$username);
 ?>

Modified: incubator/olio/webapp/php/trunk/public_html/approveFriendship.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/approveFriendship.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/approveFriendship.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/approveFriendship.php Tue Jan 13 20:54:18
2009
@@ -28,10 +28,12 @@
 $person = $_REQUEST['person'];
 $friend = $_REQUEST['friend'];
 $approveSql = "update PERSON_PERSON set is_accepted=1 where person_username='$person' and
friends_username='$friend'";
+$connection->beginTransaction();
 $connection->exec($approveSql);
 $_SESSION["friendshipreqs"]=$friends->numFriendshipRequests($person,$connection);
 $incomingRequests = $friends->incomingRequests($person,$connection);
 $friendCloud = $friends->getFriendCloud($person,$connection);
+$connection->commit();
 echo "friendship requests (".$_SESSION["friendshipreqs"].")\n";
 echo $friendCloud."\n".$incomingRequests;
 ?>

Modified: incubator/olio/webapp/php/trunk/public_html/deleteAttendee.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/deleteAttendee.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/deleteAttendee.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/deleteAttendee.php Tue Jan 13 20:54:18 2009
@@ -30,6 +30,7 @@
 if(!is_null($username)){
     $connection = DBConnection::getWriteInstance();
     $deleteuser = "delete from PERSON_SOCIALEVENT where username='$username' and socialeventid='$se'";
+    $connection->beginTransaction();
     $connection->exec($deleteuser);
 }
 
@@ -43,8 +44,14 @@
         $tmp_uname = $listqueryresult->get(1);
         $attendeeList = $attendeeList." ".'<a href="users.php?username='.$tmp_uname.'">'.$tmp_uname.'</a><br
/>';
 }
+
+unset($listqueryresult);
+
+if (!is_null($username)) {
+    $connection->commit();
+}
+
 $numofattendees = $_SESSION["numofattendees"] - 1;
 $_SESSION["numofattendees"] = $numofattendees;
 echo '<h2 class="smaller_heading">'.$numofattendees.' Attendees:</h2><br/><input
name="attend" type="button" value="Attend" onclick="addAttendee();"/><br/><div
id="attendees">'.$attendeeList.'</div>';
-unset($listqueryresult);
 ?>

Modified: incubator/olio/webapp/php/trunk/public_html/deleteCommentsRating.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/deleteCommentsRating.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/deleteCommentsRating.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/deleteCommentsRating.php Tue Jan 13 20:54:18
2009
@@ -31,6 +31,7 @@
 $commentid = $_REQUEST['commentid'];
 $se= $_REQUEST['socialEventID'];
 $deleteCommentsRating = "delete from COMMENTS_RATING where commentid='$commentid'";
+$connection->beginTransaction();
 $connection->exec($deleteCommentsRating);
 
 $commentsratingSql = "select commentid,username,comments,ratings,created_at,updated_at from
COMMENTS_RATING where socialeventid ='$se'";
@@ -46,6 +47,7 @@
 require("../views/commentsRating.php");
 }
 unset($commentsratingResult);
+$connection->commit();
 $eventCommentsRating = ob_get_contents();
 ob_end_clean();    
 

Modified: incubator/olio/webapp/php/trunk/public_html/events.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/events.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/events.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/events.php Tue Jan 13 20:54:18 2009
@@ -28,16 +28,19 @@
 $comments = $_POST['comments'];
 $cid = $_POST['editingcid'];
 $editcomments = $_POST['editcomments'];
-if (isset($_POST['commentsratingsubmit']) || 
+$tagslist = Tags_Controller::getInstance();
+$events = Events_Controller::getInstance();
+$username = $_SESSION["uname"];
+$dateFormat = "l,  F j,  Y,  h:i A";
+$txBegun = false;
+if (isset($_POST['commentsratingsubmit']) ||
     (isset($_POST['editcommentsratingsubmit']) && isset($_POST['editingcid']))) {
     $connection = DBConnection::getWriteInstance();
+    $connection->beginTransaction();
+    $txBegun = true;
 } else {
     $connection = DBConnection::getInstance();
 }
-$tagslist = Tags_Controller::getInstance();
-$events = Events_Controller::getInstance();
-$username = $_SESSION["uname"];
-$dateFormat = "l,  F j,  Y,  h:i A";
 $eventTaglist = $tagslist->getEventsPageTagCloud($connection,$se);
 $numAttendees = $events->getNumAttendees($se,$connection);
 $_SESSION["numofattendees"] = $numAttendees;
@@ -105,6 +108,11 @@
 require("../views/commentsRating.php");
 }
 unset($commentsratingResult);
+
+if ($txBegun) {
+    $connection->commit();
+}
+
 $eventCommentsRating = ob_get_contents();
 ob_end_clean();
 ob_start();

Modified: incubator/olio/webapp/php/trunk/public_html/friends.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/friends.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/friends.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/friends.php Tue Jan 13 20:54:18 2009
@@ -57,7 +57,8 @@
     $next_page = $numPages;
     }
 }else{
-    $query = "select count(*) as count from PERSON as p, PERSON_PERSON as pp where pp.person_username='$user'
and p.username=pp.friends_username and pp.is_accepted=1";
+    $query = "select count(*) as count from PERSON_PERSON ".
+             "where person_username='$user' and is_accepted=1";
     $result = $connection->query($query);
     $row = $result->getArray();
     $count = $row['count'];

Modified: incubator/olio/webapp/php/trunk/public_html/rejectInvite.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/rejectInvite.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/rejectInvite.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/rejectInvite.php Tue Jan 13 20:54:18 2009
@@ -29,9 +29,11 @@
 $person = $_REQUEST['person'];
 $friend = $_REQUEST['friend'];
 $rejectSql = "delete from PERSON_PERSON where person_username='$person' and friends_username='$friend'";
+$connection->beginTransaction();
 $connection->exec($rejectSql);
 $_SESSION["friendshipreqs"]=$friends->numFriendshipRequests($person,$connection);
 $incomingRequests = $friends->incomingRequests($person,$connection);
+$connection->commit();
 echo "<font color=green>You rejected ". $friend."'s friendship request.</font>\n";
 echo "friendship requests (".$_SESSION["friendshipreqs"].")\n";
 echo $incomingRequests ;

Modified: incubator/olio/webapp/php/trunk/public_html/revokeInvite.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/revokeInvite.php?rev=734327&r1=734326&r2=734327&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/revokeInvite.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/revokeInvite.php Tue Jan 13 20:54:18 2009
@@ -29,8 +29,10 @@
 $person = $_REQUEST['person'];
 $friend = $_REQUEST['friend'];
 $revokeSql = "delete from PERSON_PERSON where person_username='$friend' and friends_username='$person'";
+$connection->beginTransaction();
 $connection->exec($revokeSql);
 $outgoingRequests = $friends->outgoingRequests($person,$connection);
+$connection->commit();
 echo "<font color=green>You have revoked your friendship request to ". $friend."</font>\n";
 echo $outgoingRequests ;
 ?>



Mime
View raw message