[prev in list] [next in list] [prev in thread] [next in thread]
List: msql-mysql-modules
Subject: Re: questions about bind_param and mysql
From: smrtalec () algxmail ! com
Date: 2004-01-29 2:56:27
Message-ID: 12dd31012d9c50.12d9c5012dd310 () algx ! net
[Download RAW message or body]
I'm attempting a search for multiple strings using the bind_param option. My \
understanding is the server will flag each string then after each string has been \
selected and exicuted I can then do a fethall_array. However the the results only \
include the last string searched. any ideas. an example query woudl be like \
[qw/%7th% %8th%/] only values for %8th% are returned. help
+++++++++++++++++<snippet>+++++++++++++++++++++++
### extract search pattern, and values and seperate into veriables
my @search_pat = @_;
my $pat = $search_pat[0];
shift (@search_pat);
my $svalue;
my $dbh = connect_try("rowan","5340brig");
my $sql = "SELECT str_no_addr, str_name_addr, cit_addr FROM \
s3a_inglewood_project_info WHERE str_name_addr LIKE ?;"; ## select rows in table \
based on search strings - only works with or my $sth = $dbh->prepare ($sql) or \
err_trap("failed to prepare statement\n"); foreach $svalue (@search_pat){
$sth->bind_param( 1, $svalue);
$sth->execute or err_trap("failed to execute statement\n");
}
my $array_ref = $sth->fetchall_arrayref();
# place field names on top
unshift @$array_ref, [ 'id no.', 'street no.', 'street name', 'city' ];
# place search values in with everything to make sure i'm getting ligit values
unshift (@$array_ref, @search_pat);
$dbh->disconnect or err_trap("failed to disconnect at get_date statement\n");
gen_table ($array_ref);
}
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=msql-mysql-modules@progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic