Hey all,<br><br>Sorry, I thought you were interested in some leasure time reading. The DBI book is nice for that. If what you&#39;re really after is something like a ref card, the SYNOPSIS of &#39;perldoc DBI&#39; is probably all you need.<br>
<br>If what you&#39;re really after is cheap scripts and your data set isn&#39;t huge, the easiest way is:<br><br>  my $rows = $dbh-&gt;selectall_arrayref( $query, undef, @values );<br><br>No prepare, bind or execute needed. <br>
<br>
If you&#39;re ever interested in what&#39;s under the hood, the DBI source is actually quiet readable. As for Class::DBI vs DBIx::Class, I won&#39;t rehash the flamewar here. Saying that, going straight DBI vs ORM should really depend on what you&#39;re doing. When you&#39;re mostly doing CRUD and accessing the same tables over and over again, then ORM is definately the goer. But if you&#39;re mostly doing custom queries and reporting and never repeating yourself, I would lean more to straight SQL.<br>
<br>Alfie<br><br><div class="gmail_quote">On Thu, Jul 16, 2009 at 5:57 PM, Tim Evans <span dir="ltr">&lt;<a href="mailto:tim.evans@sputnikagency.com">tim.evans@sputnikagency.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I would add to sam&#39;s list ...<br>
<br>
        $dbh-&gt;{mysql_enable_utf8} or die &quot;couldn&#39;t init mysql_enable_utf8&quot;;<br>
<br>
And as long as the db is set  up to support utf8<br>
<br>
        $dbh-&gt;do(&quot;SET character_set_database=utf8&quot;);<br>
        $dbh-&gt;do(&quot;SET character_set_server=utf8&quot;);<br>
        $dbh-&gt;do(&quot;SET names &#39;utf8&#39;&quot;);<br>
        etc.....<br>
<div><div></div><div class="h5"><br>
<br>
On 16/07/09 5:38 PM, &quot;Sam Watkins&quot; &lt;<a href="mailto:sam@nipl.net">sam@nipl.net</a>&gt; wrote:<br>
<br>
&gt;&gt; I want a handy &#39;desk&#39; reference with<br>
&gt;&gt;<br>
&gt;&gt; a) Lots of examples<br>
&gt;&gt; b) Easy to read and complete reference material<br>
&gt;&gt;<br>
&gt;&gt; The reason is that I can&#39;t hold the details in my head (because I do<br>
&gt;&gt; not DBI regularly) , but I need to keep knocking off dirty that little<br>
&gt;&gt; scripts that run sql queries. I figure the easiest way for that is SQL<br>
&gt;&gt; via DBI rather than an abstraction module.<br>
&gt;<br>
&gt; Here is a little &quot;handy desk reference&quot; for you, covering all of DBI<br>
&gt; that you should use.  It is shorter than the manpage or a book ;)<br>
&gt;<br>
&gt; my $dbh =<br>
&gt; DBI-&gt;connect(&quot;DBI:mysql:database=$database;host=$hostname;port=$port&quot;,<br>
&gt; $username, $password);<br>
&gt; my $sth = $dbh-&gt;prepare(&quot;SELECT foo, bar FROM baz WHERE foo = ? AND bar<br>
&gt; = ?&quot;);<br>
&gt; $sth-&gt;execute(&quot;foovalue&quot;, $barvalue);<br>
&gt; while (my $row = $sth-&gt;fetchrow_arrayref) {<br>
&gt;   my ($foo, $bar) = @$row;<br>
&gt;   print &quot;$foo  $bar\n&quot;;<br>
&gt; }<br>
&gt; $sth-&gt;finish;<br>
&gt;<br>
&gt;<br>
&gt; You should rarely need to use anything other than the above from DBI.<br>
&gt; keep it simple!<br>
&gt;<br>
&gt; I highly recommend using the &quot;bind values&quot; stuff with the ?s in the SQL<br>
&gt; and corresponding parameters to execute.  DBI will quote and escape<br>
&gt; values for you correctly so you don&#39;t need to worry about SQL injection<br>
&gt; attacks, etc.<br>
&gt;<br>
&gt; DBI has umpteen different fetch methods, your life will be easier if you<br>
&gt; just use one of them.<br>
&gt;<br>
&gt; regards,<br>
&gt;<br>
&gt; Sam<br>
&gt; _______________________________________________<br>
&gt; Melbourne-pm mailing list<br>
&gt; <a href="mailto:Melbourne-pm@pm.org">Melbourne-pm@pm.org</a><br>
&gt; <a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br>
<br>
_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br>
</div></div></blockquote></div><br>