Date index for May 2003


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [achievo] group, count, any one?



The First one looked better for me as I wanted to expand it to atkgroupAttribute, and use other group functions (like SUM),
But then I get problems while doing CountDB for the nav bar,
I had to override this member function in each inherited node that uses atkGroupAttribute.
Is there any way to avoid this override and use some super-duper flag?


BTW:
while working with achievo for the last 6 months or so, I've changed the class.atkmysqldb.inc in 2 places, and that made my life much easier:
1. dropped the mysql_pconnect and use mysql_connect instead, for APACHE with PHP as Dynamic module it had better performances (I get something like 70 hits a second);
2. I've disabled the function nextid and just returned NULL, that should avoid this autocount problems I've encountered using mysql.
Maybe someone will find it useful for him as well


Thanks,
Eldad.



From: Ivo Jansch <ivo dot  Reply-To: achievo dot  To: achievo dot  Subject: Re: [achievo] group, count, any one?
Date: Mon, 05 May 2003 11:26:42 +0200
MIME-Version: 1.0
Received: from s2.ibuildings.nl ([213.133.42.35]) by mc10-f34.bay6.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Mon, 5 May 2003 02:27:38 -0700
Received: (qmail 17571 invoked by uid 87); 5 May 2003 09:27:10 -0000
Received: (qmail 17567 invoked from network); 5 May 2003 09:27:09 -0000
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Mailing-List: contact achievo-help dot  Precedence: bulk
X-No-Archive: yes
List-Post: <
X-Accept-Language: nl, en-us, en
References: <Law8-F26IEAOeIiGXix0002120d dot  In-Reply-To: <Law8-F26IEAOeIiGXix0002120d dot  Return-Path: achievo-return-1683-elran70=hotmail.com dot  X-OriginalArrivalTime: 05 May 2003 09:27:39.0113 (UTC) FILETIME=[92347590:01C312E8]


Hi,

e r wrote:

I need to use grouping with count function netween two nodes, is there any "nice" way to do that or I'll need to make a dirty hack for it?
10x,
Eldad Ran.

Now the easy way. This is a lot easier to understand and implement. However, it does a new query for each record that's being displayed.


class myCountAttribute extends atkAttribute
{
  function load($db, $rec, $mode="")
  {
    $childnode = &getNode("mymodule.childnode");
    if (is_object($childnode))
    {
      // $rec is the 'master' record, we can use it's id-field to
      // count records in another node.
      return $childnode->countDb("parent_id='".$rec["id"]."'",
                                                       "","",$mode);
    }
    else
    {
      // node not found.
      return 0;
    }
  }

  function store($db, $rec, $mode="")
  {
    // dummy impl, we don't have anything to store
  }
}

This approach has several advantages. First of all, it's a lot less code. Second, it's very easy to generalize this to a generic attribute
that you can use in any situation (by passing the nodename and where clause as parameters). And you don't use the (somewhat difficult) database abstraction layer. The last advantage is that you use $childnode to access the count. Any filters that might have been set in
$childnode will be applied.


Greetings,
Ivo



[ Achievo mailing list - http://www.achievo.org/ ]
[ to unsubscribe send an e-mail to achievo-unsubscribe dot 

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



http://www.achievo.org/lists achievo.org - ©1999-2002 ibuildings.nl BV