meerdere-querys-tegelijk-uitvoeren-mysql-
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset($_POST['submit']))
{
$query = "SET AUTOCOMMIT=0";
$result_query = mysql_query($query, $connect);
$query = "
UPDATE
[i]tabelnaam[/i]
SET
geld = geld-100
WHERE
user_id = 1
";
if(!$result_query = mysql_query($query, $connect))
{
$query = "ROLLBACK";
$result_query = mysql_query($query, $connect);
}
else {
$query = "
UPDATE
[i]tabelnaam[/i]
SET
geld = geld+100
WHERE
user_id = 2
";
if(!$result_query = mysql_query($query, $connect))
{
$query = "ROLLBACK";
$result_query = mysql_query($query, $connect);
}
else {
$query = "SET AUTOCOMMIT=1";
$result_query = mysql_query($query, $connect);
}
}
}
}
?>
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset($_POST['submit']))
{
$query = "SET AUTOCOMMIT=0";
$result_query = mysql_query($query, $connect);
$query = "
UPDATE
[i]tabelnaam[/i]
SET
geld = geld-100
WHERE
user_id = 1
";
if(!$result_query = mysql_query($query, $connect))
{
$query = "ROLLBACK";
$result_query = mysql_query($query, $connect);
}
else {
$query = "
UPDATE
[i]tabelnaam[/i]
SET
geld = geld+100
WHERE
user_id = 2
";
if(!$result_query = mysql_query($query, $connect))
{
$query = "ROLLBACK";
$result_query = mysql_query($query, $connect);
}
else {
$query = "SET AUTOCOMMIT=1";
$result_query = mysql_query($query, $connect);
}
}
}
}
?>