in reply to Re^2: DBI disconnect database errors
in thread DBI disconnect database errors
OK, being able to look at that code, I wold explicitly NOT to do that. I would not explicitly prepare something for a single select, use selectrow_hashref instead, and put in the sql an explicit `LIMIT 1`. Also, using '*' should be reserved, when you want all the rows in the table. This should hold true if one of those rows is a 50 meg block of text.
Also, in your second example you could just as well do that in one query right? Through a join. This saves work on the DB.
Or, if you wanted precisely the same as above, which will render the row from table1 random because the lack of a sort order on table, you can still do that in one statement$dbh->selectrow_hashref( 'SELECT t1.* FROM table AS t0' . ' JOIN table1 AS t1' . ' USING ( primarykeyfield )' );
$dbh->selectrow_hashref( 'SELECT t1.* FROM table AS t0' . ' WHERE t1.primarykeyfield IN ( SELECT primarykeyfield FROm tabl +e LIMIT 1 ) );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: DBI disconnect database errors
by Anonymous Monk on Nov 16, 2009 at 16:51 UTC |