r> Seems that you are not taking advantage of Perl. This is what you can do:

No, he is taking advantage of placeholders. It is much better to use
placeholder for value substitution that substitute values directly
into query with Perl because there is no need to escape values (do you
know that $dbh->quote doesn't quote reliably?) and $sth can be reused
for simular queries (which can give perfomance gain on some SQL
databases).

However usually placeholders can be used only for value
substitutuion. 'DESC' cannot be substituted since it is a part of
query.

r> $parentid = x;
r> $orderby = 'DESC';
r>    my $sth = $dbh -> prepare (qq{
r>          SELECT message.name, contents, user.name, message.id
r>          FROM message, user
r>          WHERE folder='N' and parentid=$parentid
r>          GROUP BY message.id
r>          ORDER BY time $orderby
r>          }) || die $dbh->errstr;

r> You can put any variable inside the string... Note that I changed the q{
r> ... } to qq{ ... }

r> $string = q{ string } is the same as $string = 'string';
r> $string = qq{ string } is the same as $string = "string";

r> Note that variables inside of strings enclosed by '' will not be translated,
r> only strings enclosed by "" (or qq{} =) ).

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to