ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Calling a Segment inside exp:query

October 03, 2012 1:35pm

Subscribe [3]
  • #1 / Oct 03, 2012 1:35pm

    ovation01

    42 posts

    Hello,

    We are upgrading to EE1 from EE1.6.9.  The query plugin statement below used to work just fine, but now I can’t get it to render the “segment” variables within the exp:query tags. If I remove the segment variables and just search for specific hard-coded data, the query outputs just fine.  Problem is I need this query to be dynamic, pulling from the URL.

    Is my formatting off?  Other ideas?

    {exp:query sql="SELECT group_id, member_id, join_date, username FROM exp_members WHERE username = '{segment_3}' AND join_date = '{segment_4}' "}
    
    Congrats, you have access, {username}!
    
    {/exp:query}

    Thank you!

  • #2 / Oct 03, 2012 1:47pm

    mark186282

    290 posts

    (removed on purpose… the following comment gives a much better solution to the original problem)

  • #3 / Oct 03, 2012 1:49pm

    ovation01

    42 posts

    UPDATE:

    OK I got the line to render by removing the spaces. IE.

    username = '{segment_3}'

    is now

    username='{segment_3}'

    NEW PROBLEM:

    It seems the exp:query plugin cannot search for a user by his join_date. It CAN output the join_date, but when join_date is used as a search criteria it fails.

    So, this line works:

    {exp:query sql="SELECT group_id, member_id, join_date, username FROM exp_members WHERE username='testuser' "}

    But this line below doesn’t render—any ideas?

    {exp:query sql="SELECT group_id, member_id, join_date, username FROM exp_members WHERE join_date='123456789' "}
  • #4 / Oct 03, 2012 1:58pm

    mark186282

    290 posts

    what are you using as a source for your join_date?

    Remember that the join_date is stored in unix timestamp format, and is the specific to the second (not just the date) of the member joining.

    If you are looking for the match of somebody joining that day, you could calculate the range and query accordingly…

  • #5 / Oct 03, 2012 2:04pm

    ovation01

    42 posts

    Thanks for the replies - I realized I was testing with an out-of-date variable that has since changed. The above code (in my 2nd post) is working now. Thank you and please close this thread.

  • #6 / Oct 05, 2012 10:35am

    Shane Eckert

    7174 posts

    Hello ovation,

    I am glad you got this worked out! Thanks for the help here Mark!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases