DBI's selectrow_array method does not support placeholders apparently. I begged to use DBIx::Simple but Corporate America has decided that I will not.

I just left a job where I did everything by myself and am now feeling the crunch of obedience slam down upon me in the shared work environment.

But I'm happier overall - 25k salary increase. Nice people. Etc, etc.

Oh, what would I have used? Why the single row query technique of DBIx::Simple which does not fall down when it comes to placeholder support.

  • Comment on I was told to use DBI::selectrow_array... but it doesn't support placeholders
  • Download Code

Replies are listed 'Best First'.
Re: I was told to use DBI::selectrow_array... but it doesn't support placeholders
by runrig (Abbot) on Mar 29, 2007 at 19:52 UTC
    Did you read the docs and notice that the placeholder arguments start at the third argument in the method (the second arg, the attributes hashref, can be undef)?

    Disclaimer: I'm not sure if I've ever tried that particular method with placeholders, but I have run into the same issue on other dbh methods using placeholders (i.e. forgetting to put the undef in).

    Also, FYI, you can still use prepared statements with those methods, as the first argument can be either a SQL string or a prepared statement handle.

      It works fine with placeholders. The only caveat is to not call it in scalar context as its behavior is undefined. If returning a single value, use parens around the scalar.

      Cheers,
      Ovid

      New address of my CGI Course.

      I dont know how I missed this:
      @row_ary = $dbh->selectrow_array($statement, \%attr, @bind_values);
      Thanks.