in reply to Re^3: DBI and JSON fields
in thread DBI and JSON fields
Sometimes I keep the placeholders in an array to mention them...
I haven't yet found a coding style for placeholders with which I'm completely happy.
For a simple query I just keep them inline:
But for more placeholders I've tried this:my $row = $dbh->selectrow_hashref("SELECT * FROM table WHERE idTable = + ?", under, $id);
IMHO that is too spread out. So instead I generally adopt this way if I have lots of placeholders.my $row = $dbh->selectrow_array("SELECT * FROM table WHERE idTable = ? + AND some_column = ? AND another_column = ? AND name = ?", under, $table_id, $column_data, $column_info, $name);
Or, if there are silly numbers of placeholders, I will preload them into an array and just pass that to the DBI method.my $row = $dbh->selectrow_array("SELECT * FROM table WHERE idTable = ? + AND some_column = ? AND another_column = ? AND name = ?", under, $table_id, $column_data, $column_info, $name);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: DBI and JSON fields
by stevieb (Canon) on Mar 13, 2024 at 08:09 UTC | |
Re^5: DBI and JSON fields
by soonix (Chancellor) on Mar 13, 2024 at 07:49 UTC | |
by stevieb (Canon) on Mar 13, 2024 at 08:16 UTC | |
by Bod (Parson) on Mar 18, 2024 at 21:43 UTC |