Everything is a Freaking DNS problem - rtfc http://127.0.0.1:8080/blog/taxonomy/term/661/0 en SELECT vs select http://127.0.0.1:8080/blog/node/522 <p>I spent way too much time this weekend trying to get the <a href="http://api.drupal.org/api/file/includes/pager.inc/5" rel="nofollow">pager</a> stuff in Drupal working for a module I`m playing with. </p> <p>I had learned a lot from the watchdog module on how paging was supposed to be working and I was trying to do the same with another database. As I got a page limited by the number of records I wanted but I couldn't find any of the fancy next, previous and page number thingies that I wanted. </p> <p>The watchdog module worked for me and I started stripping the watchdog module till I could actually replace my function with watchdog_overview function. Even replaced the watchdog query with my qeury.. but not such luck.. I couldn't get $output .= <span class="geshifilter"><code class="text geshifilter-text">theme('pager', NULL, 50, 0);</code></span> to work.</p> <p>So as every open source geek does.. I started looking into the code. pager.inc<br /> The header told me the author.. I could mail him and wait or even call him , , but I read on.<br /> <span class="geshifilter"><code class="text geshifilter-text">$pager_total_items[$element] = db_result(db_query($count_query, $args));</code></span><br /> Never returned anything useful.., my mysql log learned me there never was any query with a count ..<br /> Till I modified the pager.inc file to actually perform the query I wanted it to do.. and it started working.<br /> Then I took a closer look at the regexp that was being used to create the $count_qeury<br /> <span class="geshifilter"><code class="text geshifilter-text">$count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''),$query);</code></span><br /> However my query was all in lowercase so the count was never inserted.</p> <p>The only difference between the working watchdog module and my own code was in the use of uppercase SQL statements.<br /> So call me lazy :)</p> http://127.0.0.1:8080/blog/node/522#comments drupal mysql newbie pager rtfc stupid Sun, 02 Dec 2007 22:56:45 +0000 Kris Buytaert 522 at http://127.0.0.1:8080/blog