Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorsilly
    • CommentTimeOct 11th 2005
     
    When I sort an album by number of comments and then try to open an image, I get the following error:

    Unknown column 'num_comments' in 'order clause'

    SELECT id FROM `plogger_pictures` WHERE parent_album = 14 ORDER BY `num_comments` DESC

    I noticed the same in the demo gallery
    •  
      CommentAuthormike
    • CommentTimeOct 11th 2005
     
    Yes, I just found this bug a couple of days ago as well and posted a ticket to the SVN repo. We'll be fixing that for the next release, thanks!
    •  
      CommentAuthormike
    • CommentTimeOct 19th 2005 edited
     
    We've fixed the problem in SVN. If you want to apply the fix to Beta 2, here is the workaround.

    Line 138 in gallery.php
    $sql .= " ORDER BY `num_comments`";

    Change it to:
    $sql = "SELECT p.`id`, COUNT(`comment`) AS `num_comments` FROM `".$TABLE_PREFIX."pictures` p LEFT JOIN `".$TABLE_PREFIX."comments` c ON p.`id`=c.`parent_id` WHERE parent_album = ".$row["parent_album"]." GROUP BY p.`id` ORDER BY `num_comments` ";
    • CommentAuthorsilly
    • CommentTimeOct 24th 2005
     
    You are missing a $ in front of TABLE_PREFIX in the workaround :P
    •  
      CommentAuthormike
    • CommentTimeOct 24th 2005
     
    Thanks, in the new version we are working on we TABLE_PREFIX defined as a macro, but for Beta 2 it should have a $ in front of it (I edited it).
  1.  
    Well, didn't work for me. I don't know what you mean with "Change it to:".
    When you insert a Select statement instead the ORDER BY clause, don't you post the query twice then?

    I tried a little bit and did it like this:


    Line 138 in gallery.php
    $sql .= " ORDER BY `num_comments`";

    Change it to:

    if($_SESSION["plogger_sortby"] == 'number_of_comments'){
    $sql = "SELECT p.`id`, COUNT(`comment`) AS `num_comments` FROM `".$TABLE_PREFIX."pictures` p LEFT JOIN `".$TABLE_PREFIX."comments` c ON p.`id`=c.`parent_id` WHERE parent_album = ".$row["parent_album"]." GROUP BY p.`id` ORDER BY `num_comments` ";
    }
    else {
    $sql = "SELECT id FROM `".$TABLE_PREFIX."pictures` WHERE parent_album = ".$row["parent_album"];


    and in line 159 (after deting) after closing the switch case, I closed the if clause with a }

    worked for me, and I am happy now :)
    •  
      CommentAuthormike
    • CommentTimeOct 28th 2005
     
    Heh. OK :)
    • CommentAuthorspck
    • CommentTimeDec 28th 2005
     
    Mike, your fix is OK for opening an image but the bug remain when you start a slideshow on an album sorted by num_comments.

    SpcK
    • CommentAuthorkingsoul
    • CommentTimeAug 1st 2006
     
    So is there a cut and paste fix for this yet, Mike? I need to get it working on my site.
    • CommentAuthorkingsoul
    • CommentTimeAug 1st 2006 edited
     
    I put your fix in. and I still get the error. here is the page http://www.konsolekingz.com/plogger/
    Everything works but the actual large view of the image.
    • CommentAuthorm0
    • CommentTimeFeb 2nd 2007
     
    kingsoul, that fix does work... Make sure your editing the correct one.

    For spck if you wish you fix the slideshow which you are correct that it is broken..
    Then change the following:

    Line 1132 in gallery.php
    Within the method
    ==============
    function generate_slideshow_js($id, $mode) {

    FIND:
    =====
    // determine sort ordering
    switch ($_SESSION["plogger_sortby"]){
    case 'number_of_comments':
    $sql .= " ORDER BY `num_comments`";

    REPLACE:
    =====
    // determine sort ordering
    switch ($_SESSION["plogger_sortby"]){
    case 'number_of_comments':
    $sql = "SELECT p.*, COUNT(`comment`) AS `num_comments` FROM `".$TABLE_PREFIX."pictures` p LEFT JOIN `".$TABLE_PREFIX."comments` c ON p.`id`=c.`parent_id` WHERE parent_album = '".$id."' GROUP BY p.`id` ORDER BY `num_comments` ";

    That should make the slideshow work.