Montego Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic
Author Message
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Fri Nov 15, 2013 5:21 am Reply with quote

Hi montego.

In admin/Categories.php

We have this

Code:
$sql = 'SELECT a.`cid`, a.`title`, a.`parentid`, a.`active`, b.`acnt`, b.`icnt` FROM `' . $prefix . '_nsngd_categories` a LEFT JOIN '
   . '(SELECT s1.`cid`, SUM(s1.`acnt`) AS acnt, SUM(s1.`icnt`) AS icnt FROM (SELECT `cid`, COUNT(`lid`) AS acnt, 0 AS icnt FROM `'
   . $prefix . '_nsngd_downloads` WHERE `active` > 0 GROUP BY `cid` UNION ALL SELECT `cid`, 0 AS acnt, COUNT(`lid`) AS icnt FROM `'
   . $prefix . '_nsngd_downloads` WHERE `active` = 0 GROUP BY `cid`) s1 GROUP BY s1.`cid`) b ON (a.`cid` = b.`cid`) ORDER BY `parentid`, `title`';
$result = $db->sql_query($sql);



Can u explain to me what is acnt and icnt? Question

I don't understand why (s1.`acnt`) should have backtick.

Montego: I just finished updating the whole module with commas and backticks succefully. Very Happy If you would like to have all the files let me know.
 
View user's profile Send private message Visit poster's website
montego
Site Admin/Owner
Site Admin/Owner



Joined: Feb 12, 2005
Posts: 1399

PostPosted: Sat Nov 16, 2013 11:00 am Reply with quote

acnt and icnt are labels needed for the inner selects so that I have something to reference in the SUMmations.

acnt = the number of active downloads
icnt = the number of inactive downloads

Regarding your other question, if you're going to go with the backtick standard, then every field, whether real or an alias, should have a backtick.

I haven't started converting over the Downloads module yet for the new CMS so I suppose if you don't mind sharing, I could compare with the current code set and incorporate. If you like, you can zip them up and send to montego --AT-- montegoscripts {{DOT}} com. But I probably will not be continuing on with the RavenNuke(tm) version go forward, only for the new CMS. I am thinking of making my scripts available using Github for old RN use; a consideration at least.

Thanks and regards,
Rob

_________________
“To err is human, but when the eraser wears out ahead of the pencil, you’re overdoing it.”
-- Josh Jenkins 
View user's profile Send private message Visit poster's website
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Sat Nov 16, 2013 7:38 pm Reply with quote

Quote:
if you're going to go with the backtick standard, then every field, whether real or an alias, should have a backtick


What do you mean with field? Can you give me examples?

Edit: I sent u already all the files by email. Wink

I guess u mean this

Code:
SELECT `some_fied`, `some_other_field` FROM whatever WHERE `id` IS NULL;
 
View user's profile Send private message Visit poster's website
montego
Site Admin/Owner
Site Admin/Owner



Joined: Feb 12, 2005
Posts: 1399

PostPosted: Tue Nov 19, 2013 8:30 am Reply with quote

People call this different things. All of the below could be the same:

field = property = column

Now, when I use inner selects, I like to alias the returned values with a name, essentially making them a "field/property/column" that can be referenced outside the inner select.

_________________
“To err is human, but when the eraser wears out ahead of the pencil, you’re overdoing it.”
-- Josh Jenkins 
View user's profile Send private message Visit poster's website
hicux
Newbie
Newbie



Joined: Jan 30, 2009
Posts: 92
Location: NL

PostPosted: Tue Nov 19, 2013 10:18 am Reply with quote

thanks for the explanation.
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 4 Hours
 
Forums ©
linear-bunch