Arrow Home arrow Forums
larger font smaller font default font Fixed screen resolution Auto adjust screen size

Joomlapolis Forums  


<< Start < Prev 1 2 3 4 5 6 7 Next > End >>
Re:Friends Updates
Date: 2008/09/24 22:47 By: krileon Status: CB Doc subscriber  
Karma: 38  
Platinum Joomlapolitan

Posts: 511
graphgraph
Alright I've been hammering at this for hours on this 1 stupid line of code to delete old entries. Someone that knows more please step up to the plate on this one, because I'm stumped.

What I'm attempting to do is count the rows in table #__liveshoutbox from field nameid and order them by id desc. Then delete any row count greater then 10. So if it has 17 rows. It should delete the 7 oldest rows.

So far it's not doing squat. I can't figure this out or even know if I'm doing it right.

I just need it to delete the old entries. Even deleting by date would be effective. Say if the entries are 1 week only. It deletes them. Something along those lines would be fine too.

Any ideas?

Here's my query that doesn't work:
Code:

 DELETE #__liveshoutbox WHERE nameid NOT IN (SELECT TOP 10 nameid FROM #__liveshoutbox ORDER BY id DESC)


AllMySocials
"Where social networks come together"
www.allmysocials.com
Click here to see the profile of this user The administrator has disabled public write access.

Re:Friends Updates
Date: 2008/09/24 23:32 By: steveometer Status: User  
Karma: 6  
Senior Joomlapolitan

Posts: 94
graphgraph
Code:

 select max id from #__...



Code:

 delete from #__... where id < maxid-10



SoM

Post edited by: steveometer, at: 2008/09/24 23:33
Click here to see the profile of this user The administrator has disabled public write access.

Re:Friends Updates
Date: 2008/09/24 23:34 By: steveometer Status: User  
Karma: 6  
Senior Joomlapolitan

Posts: 94
graphgraph
well i suppose...

Code:

 delete from #__... where ( id < ( max id ) )

Click here to see the profile of this user The administrator has disabled public write access.

Re:Friends Updates
Date: 2008/09/25 00:05 By: krileon Status: CB Doc subscriber  
Karma: 38  
Platinum Joomlapolitan

Posts: 511
graphgraph
Don't think I'm setting it up right, but it's not working.

The whole query thing is fairly new to me so if you could be as so kind to be a bit more detailed then I'd really appreciate it.

This is what I have:
Code:

                                 $query "SELECT MAX nameid FROM #__liveshoutbox"                                        "DELETE FROM #__liveshoutbox WHERE ( nameid < ( MAX nameid ) )";



Also if it helps. This is the query to get the updates:
Code:

                                 $sql "SELECT *"                                      "\n FROM #__liveshoutbox AS a, #__comprofiler_members as b"                                      "\n WHERE b.memberid = a.nameid"                                      "\n AND b.referenceid=".$my->id                                      "\n AND b.accepted=1 AND b.pending=0"                                      "\n ORDER BY a.id DESC";



Here's the PHP file if anyone wants to poke around in it and see what can be done about deleting the old entries. I sure as heck can't figure it out.
File Attachment:
File name: cb_friendsupdates_alpha.zip
File size:2141 bytes


Post edited by: krileon, at: 2008/09/25 01:30
AllMySocials
"Where social networks come together"
www.allmysocials.com
Click here to see the profile of this user The administrator has disabled public write access.

Re:Friends Updates
Date: 2008/09/25 01:55 By: krileon Status: CB Doc subscriber  
Karma: 38  
Platinum Joomlapolitan

Posts: 511
graphgraph
I don't get it. This is extremely frustrating. This should work perfectly fine.

Code:

                                 $query "DELETE FROM #__liveshoutbox WHERE nameid='66'"                                        "ORDER BY id DESC LIMIT 10";                                 $database->setQuery($query);



66 would be replaced obviously, but as a test I let it run and NOTHING happened. What in the heck is going on with this. User 66 has over 20 rows. It should have deleted all but the 10 newest.
AllMySocials
"Where social networks come together"
www.allmysocials.com
Click here to see the profile of this user The administrator has disabled public write access.

Re:Friends Updates
Date: 2008/09/25 01:58 By: steveometer Status: User  
Karma: 6  
Senior Joomlapolitan

Posts: 94
graphgraph
krileon wrote:
I don't get it. This is extremely frustrating. This should work perfectly fine.

Code:

                                 $query "DELETE FROM #__liveshoutbox WHERE nameid='66'"                                        "ORDER BY id DESC LIMIT 10";                                 $database->setQuery($query);



66 would be replaced obviously, but as a test I let it run and NOTHING happened. What in the heck is going on with this. User 66 has over 20 rows. It should have deleted all but the 10 newest.


Code:

                                 $query "DELETE FROM #__liveshoutbox WHERE nameid='66' "                                        "ORDER BY id DESC LIMIT 10";                                 $database->setQuery($query);



can you tell me, specifically the difference?

it is literally a matter of 1 charachter

Post edited by: steveometer, at: 2008/09/25 01:59
Click here to see the profile of this user The administrator has disabled public write access.

<< Start < Prev 1 2 3 4 5 6 7 Next > End >>

Documentation

Documentation Subscription Service
(updated for CB 1.2 RC4)

What?

Why?

Where?

Just click here for answers!

Click here for a yearly subscription: subscribe now

Download Latest Release

The latest stable Community Builder Release is version 1.1 for Joomla 1.0 and Mambo.
You need to be a registered member of Joomlapolis to download.

The latest release candidate of Community Builder is version 1.2 RC4, native for Joomla 1.0, 1.5 and Mambo.
It is available as "thank you" to all CB documentation subscribers and now also to all registered joomlapolitans.

CB Login