newbie

Dec 03 2007

SELECT vs select

I spent way too much time this weekend trying to get the pager stuff in Drupal working for a module I`m playing with.

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.

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 .= theme('pager', NULL, 50, 0); to work.

So as every open source geek does.. I started looking into the code. pager.inc
The header told me the author.. I could mail him and wait or even call him , , but I read on.
$pager_total_items[$element] = db_result(db_query($count_query, $args));
Never returned anything useful.., my mysql log learned me there never was any query with a count ..
Till I modified the pager.inc file to actually perform the query I wanted it to do.. and it started working.
Then I took a closer look at the regexp that was being used to create the $count_qeury
$count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''),$query);
However my query was all in lowercase so the count was never inserted.

The only difference between the working watchdog module and my own code was in the use of uppercase SQL statements.
So call me lazy :)

Oct 07 2007

Newbie Drupal Experiences

Every once in a while you start with something new.. you're used to being rather expercienced on different topics in open source , having written an article and a book left or right but there comes a day when you will feel a total newbie again :)

About 10 years ago I was mostly into technical webdevelopment , perl, php, oracle plsql , java servlets , coldfusion stuff like that.. I stopped building corporate websites about 7-8 years ago when I realised I was spending more time helping people to build the infrastructure to host those sites than actually building the sites. (That and the fact that I really got bored with people wanting greener green)

So fast forward to about 5-6 months ago where I suddenly felth the need again to start writing code for a small pet project of mine.

I wanted a framework where I could jumpstart with different features I needed such as usermanagement and a blog feature.

As I mentionned earlier this week .. everybody seems to be using Drupal these days and has similar newbie feelings :)

Dag is posting about his experiences on how to use Drupal as a personal blog. So my current project is different.

For a personal blog I wouldn't be using the blog module either has he describes, but as I wanted different authors .. I understood I do need it.

I had the same problem with the Vocabularies and Terms .. Upon starting I really didn't understand what they meant for my blog. So I recreated the categories I had in dotclear in there. I deleted them from my database after a month, when I figured out how to use tagging in the blog :)

So what do you need when you want to go one step further, like getting content from a database. So here is where the I probably went totally wrong and where the documentation could use a hand.

I started out writing my own module where I use some drupal functions and custom php code. Turns out there is something like CCK but I`m still not sure if CCK is the thing I need (or how to use it)

I`m pretty sure the way I`m writing my modules totally wrong also.
I'm having 1 big file in which I do everything.. Pretty crappy if you ask me but I don't really find another way .. Or should I create multiple modules ?

Luckily this is just a hobby, won't be big and professional like... It's just a project to learn and I got a different dayjob ..
However my fear is that other people probably won't realize how wrong the
are using a certain technology and will offer their services to customers :(

So I`m nagging some people about a new Drupal User group meeting.
Guess Dag and I will learn some stuff there ;)