count_search_where deleting its parameters ?
[prev]
[thread]
[next]
[Date index for 2005/01/08]
I am not sure where count_search_where comes from, but it
seems to be eating its parameters.
I am using Class::DBI::Plugin::Pager
and trying to use a query such as this:
age <= 80 AND age >= 20 AND city = Jerusalem
In SQL::Abstract I can do this by
$sql = SQL::Abstract->new(logic => 'and');
print $sql->where([
age => {'<=', 80},
age => {'=>', 20},
city => 'Jerusalem',
]), "\n";
That is, supplying an ARRAY ref as the where clause.
IN CDPP it seems that I cannot do this.
I tried to setup
my $pager = __PACKAGE__->pager();
$pager->per_page(10);
$pager->page(1);
$pager->where(\@where);
$pager->order_by($order_by);
$pager->abstract_attr({logic => 'and'});
#$pager->set_syntax();
$pager->search_where;
but it does not work.
From the error log it seems my where clause has disappeared.
As far as I could track down in
sub _setup_pager { (of CDPP)
this line causes the trouble:
my $count = $cdbi->count_search_where( $where );
before that line I still have $self->where
after that line $self->where returns and empty ARRAY ref
It seems that
my $count = $cdbi->count_search_where( $where );
eats the content of the ARRAY ref.
While I guess this is a bug somewhere else putting the following
two lines
$where = [@$where] if ref($where) eq 'ARRAY';
$where = {%$where} if ref($where) eq 'HASH';
before the call to cdbi seems to solve the problem for CDPP
by sending a copy of the ARRAY to cdbi.
But if I am correct this would affect other uses of CDBI as well.
Gabor
|
count_search_where deleting its parameters ?
Gabor Szabo 07:03 on 08 Jan 2005
|