• Resolved gregboutin2

    (@gregboutin2)


    I’ve now been banging my head against a “virtwall” for a few hours so I figured I’m going to call for some help now. Hopefully I’m posting this in the right place, otherwise let me know.

    I am customizing a function in my theme that shows Latest Comments, in order to show them only for a given category.

    I leveraged the code below, which I created to show commentators per category by tweaking the Top Commentators plugin, and works fine:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    If anyone good with mysql/php could take a look to tell me if there is something obviously wrong with that code, that would be great.
    The code works if I remove the last 2 LEFT OUTER joins.
    Strangely, it also returns empty results if I change FROM $wpdb->comments to FROM $wpdb->comments as co, something I can’t explain.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter gregboutin2

    (@gregboutin2)

    A follow-up question, which I think is somewhat unrelated, but better be safe than sorry:

    do you need to prepend the table names with the “prepend expression” that was requested by mysql upon DB creation?
    More concretely: my comment table is named greg_comments, but I noticed that calling it by using just the name “comments” is fine, as the first code set above shows.

    I changed my second code set to add “greg_” before every table name but it still returns empty sets…

    Thread Starter gregboutin2

    (@gregboutin2)

    Ok apparently I had to use a pastebin for my code, sorry for not knowing.

    Here is the link to both code sets:
    https://wordpress.pastebin.ca/2053837

    Thread Starter gregboutin2

    (@gregboutin2)

    Ok I got it to work. Now it shows comments per category only.

    Not sure what was wrong in the other code but I’m happy to share the new code if anyone’s interested. Basically i used the first code set and injected the mysql code from the 2nd code set, with some tweaks of course.
    One important thing is I had to use INNER JOIN instead of LEFT OUTER JOINs for the last 2.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unclear MySQL troubles’ is closed to new replies.