Menu

Backlinks plugin sort problems

Help
2005-03-31
2012-10-11
  • Stefan Schorn

    Stefan Schorn - 2005-03-31

    Hallo,

    using latest CVS Version, i have several Problems with BackLinks Plugin.

    <?plugin BackLinks page="SammlerSteckbriefe/Collector" info=hits ?> produces an unsorted list of pages - 1.3.10 it was sorted.

    Klicking on pagename to sort the list produces a database error

    lib/WikiDB/backend/PearDB.php (In template 'body' < 'html'):1014: Error: wikidb_backend_peardb_mysql: fatal database error

    * DB Error: unknown error
    * (SELECT linker.id as id, linker.pagename as pagename, linker.hits as hits FROM wiki_link, wiki_page linker, wiki_page linkee, wiki_nonempty WHERE linkfrom=linker.id AND linkto=linkee.id AND linkee.pagename='SammlerSteckbriefe/Collector' AND wiki_nonempty.id=linker.id AND linker.pagename NOT IN ('SammlerSteckbriefe/Collector') ORDER BY $want.pagename ASC [nativecode=1109 ** Unknown table '$want' in order clause])
    

    Regards Stefan

     
    • Stefan Schorn

      Stefan Schorn - 2005-03-31

      it looked at the code in PageList.php and PearDB.php and figured out a work arround for my problem. But this should be fixed language speciffic for phpwiki.

      Maybe like the code on end of the php manuale page here
      http://de3.php.net/manual/de/function.usort.php

      PageList.php cleared the function _sortPages()
      thats the rest of it

      function _sortPages() {
      }
      

      PearDB.php

      changed the type of sorting to database sorting like this

      Here is my work arround. I hope the code is shown correct. in the past it was'nt

      function get_links($pagename, $reversed=true, $include_empty=false, $sortby=false, $limit=false, $exclude='') {
      $dbh = &$this->_dbh;
      extract($this->_table_names);

          if ($reversed)
              list($have,$want) = array('linkee', 'linker');
          else
              list($have,$want) = array('linker', 'linkee');
          if ($sortby) {
              $direction = substr($sortby,0,1);
              $sortcond = substr($sortby,1);
            if ($direction == &quot;-&quot;) $direction = &quot;ASC&quot;;
            if ($direction == &quot;+&quot;) $direction = &quot;DESC&quot;;
            $orderby = &quot; order by &quot; . $want . &quot;.&quot; . $sortcond  . &quot; &quot; . $direction;
          }
          else {
      
              $orderby = &quot; order by $want.pagename ASC&quot;;
          } ;
      
          if ($exclude) // array of pagenames
              $exclude = &quot; AND $want.pagename NOT IN &quot;.$this-&gt;_sql_set($exclude);
          else 
              $exclude='';
      
          $qpagename = $dbh-&gt;escapeSimple($pagename);
      
          $sql = &quot;SELECT $want.id as id, $want.pagename as pagename, $want.hits as hits&quot;
                    .&quot; FROM $link_tbl, $page_tbl linker, $page_tbl linkee&quot;
              . (!$include_empty ? &quot;, $nonempty_tbl&quot; : '')
              . &quot; WHERE linkfrom=linker.id AND linkto=linkee.id&quot;
              . &quot;  AND $have.pagename='$qpagename'&quot;
              . (!$include_empty ? &quot; AND $nonempty_tbl.id=$want.id&quot; : &quot;&quot;)
              //. &quot; GROUP BY $want.id&quot;
              . $exclude
              . $orderby;
              /*.&quot; order by $want.pagename&quot;;            */
          if ($limit) {
              // extract from,count from limit
              list($from,$count) = $this-&gt;limit($limit);
              $result = $dbh-&gt;limitQuery($sql, $from, $count);
          } else {
              $result = $dbh-&gt;query($sql);
          }
      
          return new WikiDB_backend_PearDB_iter($this, $result);
      }
      

      Regards Stefan

       
    • Stefan Schorn

      Stefan Schorn - 2005-03-31

      Ok second Problem is solved, there is a problem in
      PearDB.php missing ' ' in function get_links

      here is the correct line ...
      if ($orderby) $orderby = 'ORDER BY ' . $want . '.' . $orderby;

      is there a way to sort it like latin1_german2_ci will do. I changed all code pages in mysql to that. in 1.3.10 this works as default sort for backlinks.

      Regards Stefan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.