(even though it peripherally involves MySQL)
This on MediaWiki 1.16.2 (Yea, I know. I will upgrade Any Day Now...)
I am trying to do conditional display, based on the result of a custom extension. This extension evaluates MySQL.
I want to include a header and table if records exist, otherwise not include the header nor the empty table.
I have an extension called "sql2wikiInline" that returns exactly one row, without column headers. I ask the table for a "count(*)" and then conditionally include the header and the result of another SQL query, this one with multiple lines and column headers.
The problem is that #ifeq: does not seem to be working as I understand it. My "sql2wikiInline" apparently appends whitespace to the end, but according to the documentation of #ifeq:, it should not matter for comparing numerics. But quoting the whitespace ("0 ") doesn't work, either.
Doing this: COUNT = "{{#tag:sql2wikiInline|SELECT count(*) FROM s_product_harvest h INNER JOIN mw_user u ON h.who1 = u.user_id WHERE u.user_name = '{{{1}}}'|database=EcoReality}}"
prints COUNT = "0 "
which I would assume #ifeq: would properly compare to an unquoted "0" numeral.
But doing this: xxx {{#ifeq:"0 "|"{{#tag:sql2wikiInline|SELECT count(*) FROM s_product_harvest h INNER JOIN mw_user u ON h.who1 = u.user_id WHERE u.user_name = '{{{1}}}'|database=EcoReality}}"|no harvests|some harvests}} xxx
prints xxx some harvests xxx
no matter what number the count(*) expression returns, with or without the quotes around the comparison parameters.
So, two questions for the parser function gurus out there:
1) Am I doing something obviously wrong? I've poked around at a few different elaborations, and can't make it work.
2) If it appears I'm using it correctly, what's my next step? How can I determine if my SQL extension is sneaking in some invisibles that are blowing #ifeq:s mind?
Thanks in advance for any assistance offered -- and I have the right list this time, I hope!
PS: this code is on a template page that includes a "some records" example: http://www.ecoreality.org/wiki/Template:Personal_statistics_for
and here is a page that uses the template above, where the record count is zero: http://www.ecoreality.org/wiki/User:Mary_Troke/Statistics
Self sign-up is disallowed and only administrators can edit pages with this extension. If you REALLY want to get in and play with it, let me know and I'll give you an admin account.
:::: The primary impediment to community is the stranglehold that hierarchical corporate-driven models of employemnt have on individuals. They so completely drain the life-energy of people in endeavors that are only marginally related to survival or fun that when people return home at the end of the day they're exhausted, suitable only for a few hours of TV and dropping into bed. -- Thom Hartmann :::: Jan Steinman, EcoReality Co-op ::::