![]() Capt. Horatio T.P. Webb |
DISC 4372 Transaction Processing II Parks -- Spring 2009 Version 1 -- Last Updated 2:00 PM 3/1/2009 |
| Function |
Execution versus HTLM |
<HTML> <BODY> Any HTML may be passed outside the script execution like here. <% execution of vbscript code starts here ... ends here %> any more HTML here </BODY> </HTML> |
<HTML> <BODY> Any HTML may be passed outside the script execution like here. <?php execution of php code starts here ... ends here ?> any more HTML here </BODY> </HTML> |
| Variables |
typeless (no declaration reqd.)
begin with any [A-Z],[a-z] contain [A-Z],[a-z],[0-9],_ e.g., some_val7 |
typeless (no declaration reqd.)
begin with $ contain [A-Z],[a-z],[0-9],_ e.g., $some_val7 |
|
Assignment
|
e.g., some_val7 = 21
e.g., some_val7 = "a string value" (same as vbscript) |
e.g., $some_val7 = 21;
e.g., $some_val7 = "a string value"; (same as javascript) |
|
Strings: Concatenation String Length Locate a string Extract a string Replace bytes uppercase lower case |
fred="String one" + "String two" fred_length = len(fred) loc_first_x = Instr(1,"abcdexfgh","x") middle3 = mid("1234567",3,3) fix_google = replace("gxxgle","x","o",2) fred = ucase("usa") alan = lcase("TURING") |
$fred="String one" . "String two"; $fred_length = strlen($fred); $loc_first_x = strpos("abcdexfgh","x"); $middle3 = substr("1234567",2,3); $fix_google = str_replace("gxxgle","x","o",2); Sfred = strtoupper("usa"); $alan = strtolower("TURING"); |
| Mathematics | same as vbscript | same as javascript |
| IF statements | same as vbscript | same as javascript |
| LOOPS | same as vbscript | same as javascript |
| Form or QueryString Data Received from the Client |
on the client form method=GET: Request.QueryString("name in the HTML object tag") or Request.QueryString (index) where index is an integer that identifies the number of the QueryString name-value pair (begins at 1) on the client form method=POST: Request.Form("name in the HTML object tag") or Request.Form (index) where index is an integer that identifies the number of the Form name-value pair (begins at 1) |
on the client form method=GET: $_GET["name in the HTML object tag"] on the client form method=POST: $_POST["name in the HTML object tag"] $_REQUEST["name in the HTML object tag"] retreives value from either GET or POST |
|
Create an ODBC
Connection or Recordset |
Set cn = Server.CreateObject("ADODB.Connection") cn.open "dbname","userid","password" someSQL_string="SELECT ..." rs.open someSQL_string,"DSN=dbname;UID=userid;PWD=password" |
$cn = odbc_connect('dbname','userid','password');
$someSQL_string="SELECT ..."; $rs = odbc_exec($cn,$someSQL_string); |
|
Recordset close Connection close |
rs.close cn.close set rs=nothing set cn=nothing | odbc_close($conn); |
|
Recordset Rollout |
set rs=Server.CreateObject("ADODB.Recordset")
someSQL="SELECT..."
rs.open someSQL,"DSN=...;UID=...;PWD=..."
while NOT rs.eof
output values are:
rs("name of column")
rs.moveNext
wend
rs.close
set rs=nothing
|
$conn=odbc_connect('...','...','...');
if (!$conn) exit("Error" . $conn);
$someSQL="SELECT...";
$rs=odbc_exec($conn,$sql);
if (!$rs)exit("rs Error in SQL");
while (odbc_fetch_row($rs))
{
output values are:
odbc_result($rs,"name of column");
}
odbc_close($conn);
|
| Simple glmaster table rollout NO error handing |
||
| Transaction Conrol |
connection_object.BeginTrans . . . connection_object.CommitTrans or connection_object.RollbackTrans |
odbc_autocommit(connection_object,false); . . . odbc_commit(connection_object); or odbc_rollback(connection_object); |
| Execute a non-query SQL i.e., INSERT or UPDATE or DELETE |
conn_object.execute SQL_string, variable
e.g.,
sql_str="UPDATE glmaster SET balance=0.0 WHERE " e.g., The int variable (e.g., numa) returns the number of records affected by the SQL statement |
$result_variable=odbc_exec(conn_object,SQL_string); $variable=odbc_num_rows($result_variable); e.g.,
$sql_str="UPDATE glmaster SET balance=0.0 WHERE "; The variable (e.g., numa) returns the number of records affected by the SQL statement |
| CREATE or DROP | same as INSERT, etc. above but returns a -1 | same as INSERT, etc. above but returns a -1 |