Re: IMPORT to ARRAY

João Ranito <[email protected]> Wed, 12 Mar 2008 14:42:15 +0000
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
Hi Joel,

Many thanks for your reply.
Indeed it worked the way you said, and now i have that cool LIST on my=20
survey doing it's job ;)

After reading your explanation, it made sense, but i have double=20
checked, and when using {$..$} on an IMPORT to VARIABLE it works,=20
whereas to ARRAY it doesn't. The previous page, where i fetch the "u_id"=20
has:

<IMPORT DBIDSN=3D"dbi:mysql:database=3Dtest" DBIUSER=3D"user" DBIPASS=3D"=
user"=20
DBITABLE=3D"users" VISIBLE=3D"no">
    <VARIABLE NAME=3D"u_id" FIELD=3D"id" />
    <VARIABLE NAME=3D"u_fname" FIELD=3D"first_name" />
    <VARIABLE NAME=3D"u_lname" FIELD=3D"last_name" />
    <FILTER CRITERIA=3D"username LIKE '{$u_name$}' AND pin LIKE=20
'{$u_pin$}'" />
</IMPORT>

and i assure you, it works(!)
Nevertheless, i will change this to use the {&..&} instead if it was not=20
meant to work the other way.

Again, thank you so much for your reply.
Jo=E3o Ranito.

Joel Palmius wrote:
> Hmm.. I'm surprised your usage of {$..$} worked anywhere in IMPORT. It=20
> shouldn't have.
>
> To explain we have to be aware that perl/variable parsing can happen=20
> at two different times: before parse and at display. The {$..$} syntax=20
> is for modifying text output at display time. It only modifies visible=20
> text output. The <IMPORT> tag happens before display and should not be=20
> possible to modify by {$..$}. Here you should rather use perl dynamics=20
> which happens before parse.
>
> I assume "u_id" is a variable which has been submitted on an earlier=20
> page. Then the following could work:
>
> <IMPORT DBIDSN=3D"dbi:mysql:database=3Dtest" DBIUSER=3D"user" DBIPASS=3D=
"user"=20
> DBITABLE=3D"places" VISIBLE=3D"yes">
>   <ARRAY NAME=3D"place" FIELD=3D"place" />
>   <ARRAY NAME=3D"p_cap" FIELD=3D"place_label" />
>   <FILTER CRITERIA=3D"user_id=3D{& print=20
> $session->getValue("SUBMITTED_u_id"); &}" />
> </IMPORT>
>
> I don't have a database available for testing at the moment, but the=20
> above should work. If it doesn't, mail any error messages and I'll=20
> take a look at it again.
>
> Don't worry that you don't know perl. It's rather a sign of health.=20
> Only really strange people and notorious nerds know perl anyway. :-)
>
>   // Joel
>
>
>
>
> On Wed, 12 Mar 2008, Jo=E3o Ranito wrote:
>
>> Hi all,
>>
>> This is my 5th day of battle with mod_survey, and my first post here=20
>> on this group, and i want first of all, to congratulate all the=20
>> people involved on this project.
>>
>> Long story short, my problem is this:
>>
>> <IMPORT DBIDSN=3D"dbi:mysql:database=3Dtest" DBIUSER=3D"user"=20
>> DBIPASS=3D"user" DBITABLE=3D"places" VISIBLE=3D"yes">
>>   <ARRAY NAME=3D"place" FIELD=3D"place" />
>>   <ARRAY NAME=3D"p_cap" FIELD=3D"place_label" />
>>   <FILTER CRITERIA=3D"user_id=3D{$u_id$}" />
>> </IMPORT>
>>
>> Running this, my Apache will say "500" after being told by MySQL to=20
>> check for the right syntax near '}'.
>>
>> u_id is ok, i checked it. It has been submitted from the previous=20
>> page, and i can see it printed ok on this page as well.
>>
>> When i replace the ARRAY by VARIABLE, i get the values of the first=20
>> row of that query, as expected, so VARIABLE works ok with {$u_id$}.
>>
>> When i replace the {$u_id$} in the FILTER by, say 1, i get all the=20
>> results ok, filtered by that id. And yes, u_id is 1 on my tests...
>>
>> So my guess is, there must be something wrong with the parsing of the=20
>> criteria on an array import. Could this be?
>>
>> The real problem is, when it comes to Perl, my level of proficiency=20
>> will allow me to develop a complete "hello world" program (standard=20
>> edition, not even enterprise), which means, when it comes to Perl, i=20
>> am totally and utterly ignorant.
>>
>> So i was wondering, could someone please help me to find out what is=20
>> wrong? is it my import? is there a way i can get those nice arrays=20
>> and put them into those cool LISTs on my survey so my users can=20
>> gracefully pick their place? that would be real nice...
>>
>> My mod_survey is 3.5.2 stable running on Apache/2.2.4 (Ubuntu)=20
>> mod_python/3.3.1 Python/2.5.1 PHP/5.2.3-1ubuntu6.3 mod_perl/2.0.2=20
>> Perl/v5.8.8 Server at 10.0.1.90 Port 80
>>
>> Thanks to everyone and,
>> Greetings from Portugal(*)
>>
>> Jo=E3o Ranito.
>> (*) Yes, mod_survey has come to the sunniest side of Europe ;)
>>
>>
>>
>> Skickat av =3D?ISO-8859-1?Q?Jo=3DE3o_Ranito?=3D <[email protected]=
>
>> till survey-discussion
>>

Skickat av =3D?ISO-8859-1?Q?Jo=3DE3o_Ranito?=3D <[email protected]>
till survey-discussion