473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

a better way to do this?

Good morning group,

Working on a generic ticketing system...each ticket can have multiple
comments, each comment can have multiple people concurring the comment
(generates a child comment record in the ticket_comments table and a
concurrence record (indicating if they approved or disapproved) in the
comment_concurrences table). Have everything working...wonderful. I
decided to print all my queries before releasing beta version and
apparently working on a very fast intranet afforded me to be sloppy!

Basically what I have going on:
The ticket class has a comments container that is an array of related
comments objects.
The comments class has a concurrence container that is an array of
concurrence objects.

When the ticket factory method is called, it calls the comments
factory method, which in turn calls the concurrence factory method.
Like I said, works fine...but right now it's using loops to generate
each concurrence set for each comment, resulting in an ever growing
number of queries for every request.

So, a new concurrence method:

public static function getTicketConcurrences ($comments) {
//@param $comments is an array of comment objects
foreach ($comments as $c) {
$c_ids[] = $c->getCommentId();
}
$res = db::getTicketConcurrences($c_ids);
while ($r = mysql_fetch_array($r)) {
$concurrence = new concurrence($r);
foreach ($comments as &$c)
{ #####
if ($c->getCommentId() == $concurrence->getCommentId())
{ #####
$c-
>addConcurrence($concurrence);
#####
}
#####
} // end foreach
} //end while
return $comments;
} // end getTicketConcurrences() method
My question is...is there a better way for me to do what I have marked
(#####)? Looping through the objects and the like just seem ugly.
Maybe an array function like array_search...but will let me look at a
specific property within the object?

Thanks,

Steve

Aug 3 '07 #1
0 1015

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: ForHimself Every Man | last post by:
What's better about Rattlesnakes than Python. I'm sure there's something. What is it? This is not a troll. I'm a snake shooping and I want people's answers. I don't know beans about...
10
by: michael newport | last post by:
Dear friends of database(s), After 13 years of Ingres, I am now using Oracle. But is Oracle technically better than Ingres. I would be much obliged if anyone could shed some light on the...
24
by: Faith Dorell | last post by:
I really donīt like C.You can write better programs in BASIC than in C, if you donīt like this language. I donīt understand how C became so popular, although much better programming languages...
39
by: bazad | last post by:
Hi, I am not using C all the time. I have a general understanding of C and nothing else. The recent reply to use strlcpy and strlcat showed me that I am not aware of the best and safe...
2
by: monkeydragon | last post by:
Which is better, using ReadFile/WriteFile or use fstream?
33
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
21
by: gavino | last post by:
why?
3
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always...
43
by: Pawel_Iks | last post by:
I've read somewhere that c++ is something more than better c ... then I talk with my friend and he claimed that c++ is nothing more than better c ... I tried to explain him that he was wrong but I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.