<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 <oleber@gmail.com><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 <beginners@perl.org><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 <<a ymailto="mailto:oha@oha.it" href="mailto:oha@oha.it">oha@oha.it</a>> wrote:<br>> On 10/07/2010 11:27 AM, marcos rebelo wrote:<br>>><br>>> but for such a simple query, I would prefer<br>>><br>>> eval {<br>>> my $ss = SmartSelect->new($dsn, $user, $password);<br>>> my $hash = $ss->select_document_by_id($id)->[0];<br>>> ...<br>>> };<br>>> if ($@) {<br>>> ...<br>>>
}<br>>><br>><br>> it's about 6 months i'm working on something like this, here a quick<br>> example:<br>><br>> # obtain a single row from db<br>> my %row = select_uniq 'select * from foo where id = ?', $id;<br>><br>> # when needed you may open a transaction<br>> tx_new<br>> {<br>> # if not differently specified, the default conenction will<br>> be used<br>> my %codes = select_map { $_{id} => $_{code} } 'SELECT * FROM<br>> codes';<br>><br>> if($code{0}) {<br>> tx_db 'master'; # going to use a specific
connection<br>><br>> my $new = select_uniq 'SELECT max(id)+1 FROM codes';<br>> tx_do 'UPDATE codes SET id = ? WHERE id = 0', $new;<br>> }<br>> # now the connection is again the default, cauz tx_db got out<br>> of scope<br>><br>> # transaction may be nested, connection will be kept<br>> separated<br>> tx_new<br>> {<br>> # if more then 1 rows is fetched, the following will<br>> confess<br>>
my %foo = select_uniq 'SELECT * FROM codes WHERE id =<br>> ?', 'foo';<br>> }<br>> } # connection will be committed and released, or rollbacked if an<br>> error is passing thru<br>><br>> It is somewhat stable and i will probably put it on CPAN, but if you are<br>> interested i can share the code<br>><br>> I'll gladly ear your thoughts about it.<br>><br>> Oha<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>><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>