You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Joshua Spoerri <jo...@yucs.org> on 2001/12/05 17:08:10 UTC
n:1 with !$Filter
is there any way for dbix '!Filter' to get one field in the database
to correspond to multiple keys in the assoc array, or vice versa?
thanks,
josh spoerri
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: n:1 with !$Filter
Posted by Gerald Richter <ri...@ecos.de>.
> On Thu, Dec 06, 2001 at 06:29:47AM +0100, Gerald Richter wrote:
> > > is there any way for dbix '!Filter' to get one field in the database
> > > to correspond to multiple keys in the assoc array, or vice versa?
> > >
> >
> > Sorry, I don't understand what you mean. Can you give a short example ?
>
> in the database you have a "full name" field,
> but in your html form, you have "first name",
> "middle initial", and "last name".
>
Ok now it's clear to me. You should be able to do this, the filter is called
with the following parameters:
Update: &{$if} ($val, 'update', $data, $where)
Insert: &{$if} ($val, 'insert', $data)
$val is the field value and $data is a hash ref of the data passed to
Update/Insert, so you can take value from there to assemble the field value
you return. You may also set the flags rqINSERT and/or rqUPDATE when
setting the filters, to make sure the filter is called anyway, also the
actual database field is not passed to Update/Insert.
Unfortunately there is no such thing for the other direction, also it should
be possible to do it (in function TIEHASH, about line 3711 in Recordset.pm)
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925131
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: n:1 with !$Filter
Posted by Joshua Spoerri <jo...@yucs.org>.
On Thu, Dec 06, 2001 at 06:29:47AM +0100, Gerald Richter wrote:
> > is there any way for dbix '!Filter' to get one field in the database
> > to correspond to multiple keys in the assoc array, or vice versa?
> >
>
> Sorry, I don't understand what you mean. Can you give a short example ?
in the database you have a "full name" field,
but in your html form, you have "first name",
"middle initial", and "last name".
or in addition to reformatting dates,
you'd like to create an "age" field,
so that mothers_bday = 1931-12-01
and fathers_bday = 1921-12-01
could come out to:
mothers_bday = 'dec 1, 1931'
fathers_bday = 'dec 1, 1921'
mothers_bday_age = '70'
fathers_bday_age = '80'
you could certainly do it in some other place (perl, javascript),
but it seems consistent to put it in !Filter.
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: n:1 with !$Filter
Posted by Gerald Richter <ri...@ecos.de>.
> is there any way for dbix '!Filter' to get one field in the database
> to correspond to multiple keys in the assoc array, or vice versa?
>
Sorry, I don't understand what you mean. Can you give a short example ?
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925131
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org