Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITN270.001 Wake Tech1 ITN270 Advanced Internet Databases Lecture 11. The Perl DBI API - Part II Topics: – Perl DBI interface to MySQL.

Similar presentations


Presentation on theme: "ITN270.001 Wake Tech1 ITN270 Advanced Internet Databases Lecture 11. The Perl DBI API - Part II Topics: – Perl DBI interface to MySQL."— Presentation transcript:

1 ITN270.001 Wake Tech1 ITN270 Advanced Internet Databases Lecture 11. The Perl DBI API - Part II Topics: – Perl DBI interface to MySQL

2 ITN270.001 Wake Tech2 Related issues for DBI with MySQL Handling Queries That Return a Results Set –Working with complete Sets use matrix contains to contain all the information Example: –fetchrow_array () –fetchrow_arrayref() –selectall_arrayref($query);

3 ITN270.001 Wake Tech3 Using fetchrow_array () Example:

4 ITN270.001 Wake Tech4 Using fetchall_arrayref() Example:

5 ITN270.001 Wake Tech5 Using selectall_arrayref($query) Example:

6 ITN270.001 Wake Tech6 Checking for NULL values Example: if (!defined ($col_val)) {print "NULL\n";} elsif ($col_val eq " ") {print "empty string\n”;} elsif ($col_val == 0) {print "zero\n";} else { print "other\n";}

7 ITN270.001 Wake Tech7 Quoting Issues Example: –Double Quotes vs. Single Quotes “SELECT * FROM member WHERE id = $var” ‘SELECT * FROM member WHERE id = $var’ –Using qq{ }, qq( ), or qq/ / $date = “2002-09-16”; $date = qq{2002-09-16};

8 ITN270.001 Wake Tech8 Binding Query Results To Script Variable It allows to parameterized the output by retrieving column values into variable automatially when fetching a row with out having to assign values to the variables yourself Example:

9 ITN270.001 Wake Tech9 Using DBI in Web Application Example: Connection

10 ITN270.001 Wake Tech10 Using DBI in Web Application Example: Issue Query

11 ITN270.001 Wake Tech11 Using DBI in Web Application Example: Read & Display data

12 ITN270.001 Wake Tech12 Using DBI in Web Application Example: Close the connection


Download ppt "ITN270.001 Wake Tech1 ITN270 Advanced Internet Databases Lecture 11. The Perl DBI API - Part II Topics: – Perl DBI interface to MySQL."

Similar presentations


Ads by Google