<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Well Marcos,<br><br>if you could help even just for a week to my CPAN project I would be really advantaged :)<br><br>it is PNI and PNI::GUI on CPAN<br><br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">Da:</span></b> marcos rebelo &lt;oleber@gmail.com&gt;<br><b><span style="font-weight: bold;">A:</span></b> milan-pm@pm.org; nl-pm@amsterdam.pm.org; perl-recipes@googlegroups.com; perl@lisbon.pm.org; Perl Begginers &lt;beginners@perl.org&gt;<br><b><span style="font-weight: bold;">Inviato:</span></b> Gio 7 ottobre 2010, 14:28:11<br><b><span style="font-weight: bold;">Oggetto:</span></b> Re: [Milan-pm]
 New note on page5notebook<br></font><br>My idea is to throw away the SQL almost completely to 90% of the<br>queries. When the queries are a little bit more complex, I'd prefer to<br>create a View and use a simple interface.<br><br>I never did a Project to CPAN, but If someone is interested in growing<br>up the code I may help as much as I can +- 5 hours/week.<br><br>Best Regards<br>Marcos Rebelo<br><br>On Thu, Oct 7, 2010 at 12:08 PM, Oha &lt;<a ymailto="mailto:oha@oha.it" href="mailto:oha@oha.it">oha@oha.it</a>&gt; wrote:<br>&gt; On 10/07/2010 11:27 AM, marcos rebelo wrote:<br>&gt;&gt;<br>&gt;&gt; but for such a simple query, I would prefer<br>&gt;&gt;<br>&gt;&gt; eval {<br>&gt;&gt; &nbsp; &nbsp;my $ss = SmartSelect-&gt;new($dsn, $user, $password);<br>&gt;&gt; &nbsp; &nbsp;my $hash = $ss-&gt;select_document_by_id($id)-&gt;[0];<br>&gt;&gt; &nbsp; &nbsp;...<br>&gt;&gt; };<br>&gt;&gt; if ($@) {<br>&gt;&gt; &nbsp; &nbsp;...<br>&gt;&gt;
 }<br>&gt;&gt;<br>&gt;<br>&gt; it's about 6 months i'm working on something like this, here a quick<br>&gt; example:<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;# obtain a single row from db<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;my %row = select_uniq 'select * from foo where id = ?', $id;<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;# when needed you may open a transaction<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;tx_new<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;{<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# if not differently specified, the default conenction will<br>&gt; be used<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my %codes = select_map { $_{id} =&gt; $_{code} } 'SELECT * FROM<br>&gt; codes';<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if($code{0}) {<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tx_db 'master'; # going to use a specific
 connection<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my $new = select_uniq 'SELECT max(id)+1 FROM codes';<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tx_do 'UPDATE codes SET id = ? WHERE id = 0', $new;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# now the connection is again the default, cauz tx_db got out<br>&gt; of scope<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# transaction may be nested, connection will be kept<br>&gt; separated<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tx_new<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# if more then 1 rows is fetched, the following will<br>&gt; confess<br>&gt; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;my %foo = select_uniq 'SELECT * FROM codes WHERE id =<br>&gt; ?', 'foo';<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;} # connection will be committed and released, or rollbacked if an<br>&gt; error is passing thru<br>&gt;<br>&gt; It is somewhat stable and i will probably put it on CPAN, but if you are<br>&gt; interested i can share the code<br>&gt;<br>&gt; I'll gladly ear your thoughts about it.<br>&gt;<br>&gt; Oha<br>&gt; _______________________________________________<br>&gt; Milan-pm mailing list<br>&gt; <a ymailto="mailto:Milan-pm@pm.org" href="mailto:Milan-pm@pm.org">Milan-pm@pm.org</a><br>&gt; <a href="http://mail.pm.org/mailman/listinfo/milan-pm" target="_blank">http://mail.pm.org/mailman/listinfo/milan-pm</a><br>&gt;<br><br><br><br>-- <br>Marcos Rebelo<br><a href="http://oleber.freehostia.com"
 target="_blank">http://oleber.freehostia.com</a><br>Milan Perl Mongers leader <a href="http://milan.pm.org" target="_blank">http://milan.pm.org</a><br>Webmaster of <a href="http://perl5notebook.oleber.com" target="_blank">http://perl5notebook.oleber.com</a><br>_______________________________________________<br>Milan-pm mailing list<br><a ymailto="mailto:Milan-pm@pm.org" href="mailto:Milan-pm@pm.org">Milan-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/milan-pm" target="_blank">http://mail.pm.org/mailman/listinfo/milan-pm</a><br></div></div>
</div><br>



      </body></html>