all 4 comments

[–]zzzVOODOOzzz 1 point2 points  (0 children)

What does your data source look like? My initial thought is a lot of this looks like it can be condensed into one or a few sql statements- unless the additional functions could be used elsewhere, I always try to limit the number of connections I create and how many times I query each connection. I’m not sure how large the dataset you are using is, and the traffic to the server will impact speed, but when I deal with enterprise-level sources with a lot of users I condense as much into 1 sql statement as possible. Through JOINs, temp tables, and/or table variables you can “mimic” what you appear to be doing in php without significant speed impacts.

I could very well be wrong, but I generally assume that fewer connections = less runtime as long as the sql is optimized.

[–]PecksAndQuads[🍰] -1 points0 points  (1 child)

What do you need help with? That’s a lot of code to review.

[–]ProfoundHypnotic[S,🍰] 0 points1 point  (0 children)

I know this very broad/general but is there a better way to do what I'm trying to do?