Beruflich Dokumente
Kultur Dokumente
0046: Database
Management Systems
Lecture #22
M.P. Johnson
Stern School of Business, NYU
Spring, 2005
Transactions
Next: Security
Secrecy
Integrity
Availability
Web issues
HTML Generated
HTML
Server
Image from http://www.scit.wlv.ac.uk/~jphb/cp3024/
M.P. Johnson, DBMS, Stern/NYU, Spring 2005 5
Form example
<form
<formmethod="get"
method="get"action="">
action="">
Enter
Enteraanumber:
number:
<input
<inputtype="Text“
type="Text“name="number"><br>
name="number"><br>
<input
<inputtype="Submit"
type="Submit"name="submit"
name="submit"value="OK">
value="OK">
</form>
</form>
<html>
<html>
<head><title>Hello
<head><title>Hello from
from PHP</title>
PHP</title>
</head>
</head>
<body>
<body>
Here
Here is
is the
the PHP
PHP part:<BR><BR>
part:<BR><BR>
<?php
<?php print
print "Hello,
"Hello, World!<br>\n";
World!<br>\n"; ?>
?>
<br>That's
<br>That's it!
it!
</body></html>
</body></html>
<?
<?
$num1
$num1 == 58;
58;
$num2
$num2 == 67;
67;
print
print "First
"First number
number "" .. $num1
$num1 .. "<br>";
"<br>";
print
print "Second
"Second number
number "" .. $num2
$num2 .. "<br>";
"<br>";
$total
$total == $num1
$num1 ++ $num2;
$num2;
print
print "The
"The sum
sum is
is "" .. $total
$total .. "<br>";
"<br>";
?>
?>
<?php
<?php
for($z=0;$z<=5;$z++)
for($z=0;$z<=5;$z++) {{
?>
?>
Iteration
Iteration number
number <?
<? == $z
$z ?><br>
?><br>
<?
<?
}}
?>
?>
<?
<? phpinfo();
phpinfo(); ?>
?>
2. Run query:
$result
$result == mysql_query($query,$db);
mysql_query($query,$db);
M.P. Johnson, DBMS, Stern/NYU, Spring 2005 14
PHP & MySQL
3. Extract next row of data from statement, if
available:
$myrow
$myrow == mysql_fetch_row($result)
mysql_fetch_row($result)
What this means: myrow is an array that can
then be accessed
Other options, but this should suffice
In general, to scroll through results, do:
while
while ($myrow
($myrow == mysql_fetch_row($result))
mysql_fetch_row($result))
## print
print row’s
row’s data
data
http://pages.stern.nyu.edu/~mjohnson/dbms/perl/update.cgi
http://pages.stern.nyu.edu/~mjohnson/dbms/perl/updatecgi.txt
http://pages.stern.nyu.edu/~mjohnson/dbms/php/update.php
http://pages.stern.nyu.edu/~mjohnson/dbms/php/updatephp.txt
http://pages.stern.nyu.edu/~mjohnson/dbms/php/cia.php?id=
http://pages.stern.nyu.edu/~mjohnson/dbms/php/ciaphp.txt
http://pages.stern.nyu.edu/~mjohnson/dbms/perl/cia.cgi
http://pages.stern.nyu.edu/~mjohnson/dbms/perl/cia.pl
PHP is fast
Perl has JDBC-like DBI/DBD interface
PHP is fast
Perl is good for much more than web dev
drop
drop table
table junk;
junk;
Examples: rollback;
rollback;
truncate
truncate table
table junk;
junk;
rollback;
rollback;
--changes
--changes
emp example: SAVEPOINT
SAVEPOINT sp1;
sp1;
--changes
--changes
Can skip savepoints SAVEPOINT
SAVEPOINT sp2;
sp2;
But can ROLLBACK --changes
--changes
only backwards SAVEPOINT
SAVEPOINT sp3
sp3
--changes
--changes
Can ROLLBACK
ROLLBACK
ROLLBACK TO
TO sp2;
sp2;
only to last COMMIT ROLLBACK TO sp1;
ROLLBACK TO sp1;
Start proj5!