Hi Mohammed,
This test app will hopefully show the difference in behaviour I get
between sasql_connect() and sasql_pconnect().
Summary of what I get:
---------------------------------
When using sasql_connect():
If the update and select queries are done in one HTTP session (request-
response) then the select shows the correct updated result.
If the update is done in one HTTP session and the select in the next
HTTP session then the select does NOT show the updated result.
When using sasql_pconnect():
The select will show the correct updated result in both cases as
described above.
file test.php:
-----------------
<html>
<head>
<title>Test</title>
<script type="text/javascript">
function performAction(action) {
document.getElementById("action").value = action;
document.myform.submit();
}
</script>
</head>
<body>
<form name="myform" action="test.php" method="post">
<input type="button" value="select"
onclick="performAction('select');" />
<input type="button" value="update"
onclick="performAction('update');" />
<input type="button" value="rollback"
onclick="performAction('rollback');" />
<input type="button" value="commit"
onclick="performAction('commit');" />
<input type="hidden" id="action" name="myaction" value="" />
</form>
</body>
</html>
<?php
$conn = sasql_connect("Uid=blah; Pwd=blah; ServerName=blah;
CommLinks=tcpip(host=blah;port=blah)");
if($_POST) {
if($_POST['myaction'] == "rollback") {
sasql_rollback($conn);
// select($conn);
}
else if($_POST['myaction'] == "commit") {
sasql_commit($conn);
// select($conn);
}
else if($_POST['myaction'] == "select") {
select($conn);
}
else if($_POST['myaction'] == "update") {
sasql_query($conn, "update ....");
// select($conn);
}
}
function select($conn) {
$data = null;
$result = sasql_query($conn, "SELECT ....");
while ($obj = sasql_fetch_object($result))
$data = $obj->test;
echo($data);
sasql_free_result($result);
}
?>
The test app has these 4 buttons:
select, update, rollback and commit
auto_commit is set to off in php.ini
With the select() function commented out as shown in the code the
following tests are performed:
Test 1 with sasql_pconnect():
select
update
select - shows the updated result correctly
Test 2 with sasql_connect():
select
update
select - does NOT show the updated result ...
Now uncomment the select() function in 3 places and test again:
Test 1 with sasql_pconnect():
produces the correct updated result
Test 2 with sasql_connect():
select
update (which includes a select()) - shows the updated result
correctly.
select (i.e. a new HTTP session)- does NOT show the updated result ...
Vartan