1
jmass
Time Tracking Beta Released
  • 2004/9/30 19:23

  • jmass

  • Friend of XOOPS

  • Posts: 524

  • Since: 2003/12/18


I have released my first beta of the OBS Time Tracking.

Please feel free to download it.

http://dev.xoops.org/modules/xfmod/project/showfiles.php?group_id=1078

And please let me know what you think. I would prefer to have bugs submitted via the dev.xoops.org site, but feedback is welcomed in this forum.

BTW - The Time Reports section does not work.

JMass

2
Mithrandir
Re: Time Tracking Beta Released

Not bad

I do feel that you could use the classes a bit better than merely as containers of SQL statements. Also with the use of Criteria objects, you could have one method with a generic SQL statements and the other methods would simply construct the CriteriaCompo to be used for retrieving the specific elements and call the generic method.

Oh - and you should put more language constants in

3
jmass
Re: Time Tracking Beta Released
  • 2004/9/30 19:58

  • jmass

  • Friend of XOOPS

  • Posts: 524

  • Since: 2003/12/18


All VERY valid points. Please keep in mind that this was my first PHP project and my first XOOPS project, so I know I have a lot to learn.

Very poor use of SQL queries (two used when one could have been) to begin with. Then the lack of Criteria Objects make it worse. For the reporting section, I will try to do better (I am working on Query Objects for that). If it will be flexablie, I will have to do better

EDIT - I see that you are referring to XOOPS specific CriteriaCampo, I did not kow that existed. I was thinking of Java related general Criteria and Query Objects. I will do more research.

Also, the language constants are a good idea. Way too much hard coded. I will be sure to correct this.

This is only about 50% done. I guess alpha would have been a better term for the release.

JMass

4
ackbarr
Re: Time Tracking Beta Released

as we spoke about this in the thread about xhelp, I'm interested in seeing this module in action. I'll play with it soon and give you my thoughts.

5
jmass
Re: Time Tracking Beta Released
  • 2004/9/30 21:44

  • jmass

  • Friend of XOOPS

  • Posts: 524

  • Since: 2003/12/18


I look forward to your feedback.

As I mentioned above I am a newbie. So you may want a better mod to integrate with.

BTW - I started to look into Criteria and CriteriaCampo. They are more than a little confusing to me. Any doc on them besides just looking at the class files?

JMass

6
ackbarr
Re: Time Tracking Beta Released

Well - there is the API documentation for both classes (CriteriaCompo and Criteria). But they take a little getting used to. Their purpose is to handle everything after the 'WHERE' in a SQL Query.

Lets say you want to retrieve every user in XOOPS with an email ending in xoops.org, with a post count of 0, listed by date of user registration (oldest to newest).

Here's what I do:

Start with the full SQL query to retrieve the records you want.

SELECT FROM xoops_users WHERE [b]email LIKE '%xoops.org' AND posts=0 ORDER BY user_regdate ASC[/b]


The criteria for your records is displayed in bold, above.

The CriteriaCompo is a container to hold all the different pieces of the criteria. In our query the pieces are:

email LIKE '%xoops.org'
posts=0

First we create a new CriteriaCompo to hold our Criteria(s)

$crit = new CriteriaCompo();


Next we create a Criteria object for each piece:
$email = new Criteria('email''%xoops.org''LIKE');
$posts = new Criteria('posts'0'=');


Then we add them to the container:
$crit->add($email);
$crit->add($posts);


To adjust the sorting and the order, both CriteriaCompo and Criteria have the setSort and setOrder functions.
$crit->setSort('user_regdate');
$crit->setSort('ASC');



To get the resulting WHERE text, use the renderWhere function
$WHERE $crit->renderWhere();

$WHERE should be 'WHERE (email LIKE '%xoops.org') AND (posts = 0)'

For an example of how to use these objects in your own SQL queries, I recommend looking at the GetObjects function in any of the files in the /kernel directory

7
jmass
Re: Time Tracking Beta Released
  • 2004/10/1 1:07

  • jmass

  • Friend of XOOPS

  • Posts: 524

  • Since: 2003/12/18


Great explaination. I will sure check this out!

I looked at the api doc. It made no sense to me at all.

One question about your example:
Quote:
$crit->setSort('user_regdate');
$crit->setSort('ASC');

Should this be?:
Quote:
$crit->setOrder('user_regdate');
$crit->setSort('ASC');


Or am I off base?

Thanks,

JMass

8
ackbarr
Re: Time Tracking Beta Released

Quote:

Should this be?:
Quote:

$crit->setOrder('user_regdate');
$crit->setSort('ASC');



Close. It should be:
$crit->setSort('user_regdate');
    
$crit->setOrder('ASC');


9
jmass
Re: Time Tracking Beta Released
  • 2004/10/1 2:41

  • jmass

  • Friend of XOOPS

  • Posts: 524

  • Since: 2003/12/18


I have been testing this out, but have a couple of questions.

1> The Where statement is all ANDs. Can you make it output ORs?

2> The WHERE statement does not include the ORDER. How do you generate this?

Thanks,

JMass

10
ackbarr
Re: Time Tracking Beta Released

1. WHERE clauses using 'OR'
The CriteriaCompo::add() function has a second, optional parameter.
Quote:

$crit->add($email);
$crit->add($posts, 'OR');

this would make $WHERE = 'WHERE (email LIKE '%xoops.org') OR (posts = 0)'

2. adding ORDER to Query
the renderWhere function does not do anything with the ORDER BY (or GROUP BY) clause. The XOOPS core uses the CriteriaElement objects like this (taken from XoopsUserHandler::getObjects())
$sql .= ' '.$criteria->renderWhere();
if (
$criteria->getSort() != '') {
    
$sql .= ' ORDER BY ' $criteria->getSort() . ' ' $criteria->getOrder();
}



Login

Who's Online

192 user(s) are online (123 user(s) are browsing Support Forums)


Members: 0


Guests: 192


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits