|
|
Re:Friends Updates
|
|
Date: 2008/09/24 22:47
|
By: krileon
|
Status:
|
|
|
Karma: 38  
|
|
Platinum Joomlapolitan  | Posts: 511 |   | |
|
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
|
|
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 |   | |
|
| Code: | select max id from #__...
|
| Code: | delete from #__... where id < maxid-10
|
SoM
Post edited by: steveometer, at: 2008/09/24 23:33
|
|
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 |   | |
|
well i suppose...
| Code: | delete from #__... where ( id < ( max id ) )
|
|
|
The administrator has disabled public write access. |
|
|
|
Re:Friends Updates
|
|
Date: 2008/09/25 00:05
|
By: krileon
|
Status:
|
|
|
Karma: 38  
|
|
Platinum Joomlapolitan  | Posts: 511 |   | |
|
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.
Post edited by: krileon, at: 2008/09/25 01:30 AllMySocials "Where social networks come together" www.allmysocials.com
|
|
The administrator has disabled public write access. |
|
|
|
Re:Friends Updates
|
|
Date: 2008/09/25 01:55
|
By: krileon
|
Status:
|
|
|
Karma: 38  
|
|
Platinum Joomlapolitan  | Posts: 511 |   | |
|
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
|
|
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 |   | |
|
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
|
|
The administrator has disabled public write access. |
|
|