Re: IMPORT to ARRAY

Joel Palmius <[email protected]> Wed, 12 Mar 2008 13:07:58 +0100 (CET)
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---481066056-1412669936-1205323678=:31080
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

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 at=20
two different times: before parse and at display. The {$..$} syntax is for=
=20
modifying text output at display time. It only modifies visible text=20
output. The <IMPORT> tag happens before display and should not be possible=
=20
to modify by {$..$}. Here you should rather use perl dynamics which=20
happens before parse.

I assume "u_id" is a variable which has been submitted on an earlier page.=
=20
Then the following could work:

<IMPORT DBIDSN=3D"dbi:mysql:database=3Dtest" DBIUSER=3D"user" DBIPASS=3D"us=
er" 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 $session->getValue("SUBMITTED_u_i=
d"); &}" />
</IMPORT>

I don't have a database available for testing at the moment, but the above=
=20
should work. If it doesn't, mail any error messages and I'll take a look=20
at it again.

Don't worry that you don't know perl. It's rather a sign of health. Only=20
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 on t=
his=20
> group, and i want first of all, to congratulate all the people involved o=
n=20
> this project.
>
> Long story short, my problem is this:
>
> <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{$u_id$}" />
> </IMPORT>
>
> Running this, my Apache will say "500" after being told by MySQL to check=
 for=20
> the right syntax near '}'.
>
> u_id is ok, i checked it. It has been submitted from the previous page, a=
nd i=20
> can see it printed ok on this page as well.
>
> When i replace the ARRAY by VARIABLE, i get the values of the first row o=
f=20
> 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 result=
s=20
> 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 will=
=20
> allow me to develop a complete "hello world" program (standard edition, n=
ot=20
> even enterprise), which means, when it comes to Perl, i am totally and=20
> utterly ignorant.
>
> So i was wondering, could someone please help me to find out what is wron=
g?=20
> is it my import? is there a way i can get those nice arrays and put them =
into=20
> those cool LISTs on my survey so my users can gracefully pick their place=
?=20
> 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 Perl/v5=
=2E8.8=20
> 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
>
---481066056-1412669936-1205323678=:31080--
Skickat av Joel Palmius <[email protected]>
till survey-discussion