The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

<!--  Presentation generated by Internet Assistant for Microsoft PowerPoint 97 -->

<HTML>
<HEAD>

<meta name="GENERATOR" content="Microsoft Internet Assistant for Microsoft PowerPoint 97">
 <TITLE>A connect_cached() example</TITLE> 
</HEAD>

<BODY     >

<CENTER>
<TABLE WIDTH=100%> 
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <A HREF="sld001.htm">First</A>&nbsp;&nbsp;
         <A HREF="sld024.htm">Previous</A>&nbsp;&nbsp;
         <A HREF="sld026.htm">Next</A>&nbsp;&nbsp;
         <A HREF="sld080.htm">Last</A>&nbsp;&nbsp;
&nbsp;&nbsp;         <A HREF="index.htm">Index</A>&nbsp;&nbsp;
         <A HREF="http://dbi.perl.org">Home</A>&nbsp;&nbsp;
         <A HREF="tsld025.htm">Text</A>&nbsp;&nbsp;
     </TD> </TR>
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <IMG SRC="img025.gif" usemap="#Objmap" WIDTH=800 HEIGHT=600 BORDER=0>
     </TD> </TR>
</TABLE>
<P>Slide 25 of 80</P>
</CENTER>
<!-- <UL>
<H2>A connect_cached() example</H2>
</UL></P>
<P><UL>
<LI><H2>Compare and contrast...
</H2>
<UL>
my $dbh = DBI-&#062connect(…);
<BR><BR>sub lookup_foo_1 {
<BR>    my ($id) = @_;
<BR>    $sth = $dbh-&#062prepare_cached("select foo from table where id=?");
<BR>    return $dbh-&#062selectrow_array($sth, $id);
<BR>}
</UL></UL><UL>
<LI><H2>with...
</H2>
<UL>
sub lookup_foo_2 {
<BR><BR>    my ($id) = @_;
<BR>    my $dbh = DBI-&#062connect_cached(…);
<BR>    $sth = $dbh-&#062prepare_cached("select foo from table where id=?");
<BR>    return $dbh-&#062selectrow_array($sth, $id);
<BR>}
<BR>
</UL></UL><UL>
<H2>Clue: what happens if the database is restarted?
</H2>
</UL><UL>
<H2>.</H2>
</UL></P>
<P>  -->
</Body>
</HTML>