CREATE TABLE foo (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
this VARCHAR(100) NOT NULL,
that VARCHAR(100) NOT NULL,
other VARCHAR(100) NOT NULL,
PRIMARY KEY(id),
UNIQUE INDEX(this, that, other)
);
####
sub find_entries
{
my $sql = "SELECT * " .
"FROM foo " .
"WHERE this " .
"LIKE '%" . $this . "%' " .
"AND that " .
"LIKE '%" . $that . "%' " .
"AND other " .
"LIKE '%" . $other . "%'";
my $sth = $dbh->prepare($sql);
$sth->execute;
...
return $entries;
}
####
sub find_entries
{
my ($this, $that, $other) = @_;
my $sth = $dbh->prepare("SELECT * " .
"FROM foo " .
"WHERE this " .
"LIKE '%" . "?" . "%' " .
"AND that " .
"LIKE '%" . "?" . "%' " .
"AND other " .
"LIKE '%" . "?" . "%'");
$sth->bind_param(1, $this);
$sth->bind_param(2, $that);
$sth->bind_param(3, $other);
$sth->execute();
...
return $entries;
}
####
*** unhandled exception in callback:
*** DBD::mysql::st bind_param failed: Illegal parameter number