[pmwiki-users] SelectQuery question

Dave Brockman daveb at oz.net
Thu Oct 9 23:33:34 CDT 2008


Ben Stallings wrote:
> Dave Brockman wrote,
> 
> 
>>I installed SelectQuery and it works fine. Thank you very much! But, I 
>>was wondering if there is a way to use page variables in the query? I'm 
>>just starting with MySQL and know very little about it. I didn't make 
>>the database I am accessing. Here's what I would like to do:
>>
>>(:selectquery columns="first_name,last_name,YEAR(death_date)" 
>>tables=actor where="MONTH(death_date) = $CurrentMonth AND 
>>DAYOFMONTH(death_date) = $CurrentDay":)
>>
>>This works fine if $CurrentMonth and $CurrentDay are replaced with 
>>numbers. I added those page variables to config.php per the 
>>MoreCustomPageVariables recipe. They work in {normal} usage.
>>
>>Is there a way to make this work? Thanks in advance!
> 
> 
> Hi, Dave!  I'm glad SelectQuery is working for you!
> 
> I'm afraid you've made it more complicated than it needs to be -- 
> MySQL's date functions default to the current time when given no value, 
> so as long as you only want to run this query for the *current* month 
> and date, you'll be better off writing the query like this:
> 
> (:selectquery columns="first_name,last_name,YEAR(death_date)"
> tables=actor where="MONTH(death_date) = MONTH() AND
> DAYOFMONTH(death_date) = DAYOFMONTH()":)
> 
> If you want to use values *other* than the current month and date, you 
> need to put the page variables' names in {braces}, like so:
> 
> (:selectquery columns="first_name,last_name,YEAR(death_date)"
> tables=actor where="MONTH(death_date) = {$TargetMonth} AND
> DAYOFMONTH(death_date) = {$TargetDay}":)
> 
> I hope this helps!
> Ben Stallings
> Interdependent Web

Hi Ben!

Thanks for your help and for SelectQuery! Slowly I learn. It's working 
now with the page variables. Thanks to SelectQuery I will finally be 
able to put my friend's database on my site. The SELECT command looks 
kind of like a Pandora's box tho.

MONTH() and DAYOFMONTH() don't work for me. Could it be the version of 
MySQL that I have? I know nothing, of course.

Dave




More information about the pmwiki-users mailing list