Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 10 Mar 2016, 21:06
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
[HELP] Removing row from table plugin query

so ive got my plugin at showthread_complete, its working pretty good =)

but im trying to add a query to it that reverses something done in showthread.php

This is the code straight from showthread.php

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So I would think to reverse that my plugin would have to be

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This doesnt give me an error, but it's not working, and threadviews table still continues to grow.

i have also tried

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

both resulting in database errors.

The goal:
if vb options are not set to update view counts immediately, each view is stored in the threadviews table. this happens with that first block of code from showthread.php

so when you view a thread that query runs, i want my query to just delete the row that first query added.

i have got this all worked out if admins update threads immediately, but i don't want to dictate their having to choose that option.

--------------- Added 10 Mar 2016 at 23:17 ---------------

this is working

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is it proper?
__________________
If you need custom work done please use Dirt RIF CustUmz
Reply With Quote
  #2  
Old 10 Mar 2016, 23:19
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Real name: Mark
You need something like:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member



Support for my products (as well as updates/new product publishing) has been moved to MHB - vBulletin Products and TAZ - Add-ons
Reply With Quote
  #3  
Old 11 Mar 2016, 00:05
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
Originally Posted by Dr.CustUmz View Post
so ive got my plugin at showthread_complete, its working pretty good =)

but im trying to add a query to it that reverses something done in showthread.php

This is the code straight from showthread.php

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So I would think to reverse that my plugin would have to be

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This doesnt give me an error, but it's not working, and threadviews table still continues to grow.

i have also tried

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

both resulting in database errors.

The goal:
if vb options are not set to update view counts immediately, each view is stored in the threadviews table. this happens with that first block of code from showthread.php

so when you view a thread that query runs, i want my query to just delete the row that first query added.

i have got this all worked out if admins update threads immediately, but i don't want to dictate their having to choose that option.

--------------- Added 10 Mar 2016 at 23:17 ---------------

this is working

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is it proper?
The original code will throw a database error, you just wont see it because its being run as a shutdown query.

You final code is fine, but you dont actually need the LIMIT 1.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #4  
Old 11 Mar 2016, 02:53
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
Originally Posted by Paul M View Post
The original code will throw a database error, you just wont see it because its being run as a shutdown query.

You final code is fine, but you dont actually need the LIMIT 1.
without the limit 1 it erases every entry of that that thread id

thread views table looks like

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

if i remove limit 1 and view thread 8, all of its instances get removed and when the cron runs to update thread view its not accurate.


update****

the problem with the method im using

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is if there is no row with that threadID in the threadviews table it adds the original view to the table.

Attached Images
File Type: jpg 2016-03-10_23-17-49.jpg (52.4 KB, 30 views)
__________________
If you need custom work done please use Dirt RIF CustUmz

Last edited by Dr.CustUmz; 11 Mar 2016 at 03:20.
Reply With Quote
  #5  
Old 11 Mar 2016, 16:49
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
Originally Posted by Dr.CustUmz View Post
without the limit 1 it erases every entry of that that thread id
Is that not what you are trying to do ?
I guess I dont understand your actual objective then.

Originally Posted by Dr.CustUmz View Post
the problem with the method im using

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is if there is no row with that threadID in the threadviews table it adds the original view to the table.
A delete query cannot add anything, ever.

You are using shutdown queries, which quite possibly get run backwards to how you define them (there isnt any guarantee what order they will run). So more likely the delete is running first, then the insert. You wont notice this if there is at least one existing record, but you will if there are none.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #6  
Old 11 Mar 2016, 17:45
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
the goal is to remove the insert that showthread.php adds through a plugin

this is the query in showthread.php

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

i can make it do what i want by editing the showthread.php using if conditions, but im trying make it so there are no file edits.

so i have my plugin set to

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

this is saying if thread viewer is thread starter remove the view that the showthread query added.

BUT

if the thread has no views in the time the cron keeps them in the threadviews table (before placing them in thread table >views column) on the hour for most forums. it will add a view to the threadviews table even if it is thread starter viewing.
__________________
If you need custom work done please use Dirt RIF CustUmz
Reply With Quote
  #7  
Old 11 Mar 2016, 21:27
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
I still dont understand the objective, why do you want to remove that record ?

Two things ;

1. Dont use db->query_first() on the delete, thats for table reads. I believe its db->query_write() you need, but Im unable to check that where I am located atm.

2. What you are doing atm isnt going to work properly, because you are running the delete before the insert.

You need to remember that shutdown queries are run when all the page processing has completed - just before vb sends the actual html back to the client (and shuts down).
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #8  
Old 12 Mar 2016, 02:40
Dr.CustUmz's Avatar
Dr.CustUmz Dr.CustUmz is offline
 
Join Date: Aug 2013
Real name: Ryan
Originally Posted by Paul M View Post
I still dont understand the objective, why do you want to remove that record ?

Two things ;

1. Dont use db->query_first() on the delete, thats for table reads. I believe its db->query_write() you need, but Im unable to check that where I am located atm.

2. What you are doing atm isnt going to work properly, because you are running the delete before the insert.

You need to remember that shutdown queries are run when all the page processing has completed - just before vb sends the actual html back to the client (and shuts down).
the recored is being removed, so if thread starter views his own thread the view counter does not go up

this is how i came up with this, i edited showthread.php (search for // update views counter)
and came up with this.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

works 100%

im trying to do the same exact thing only without having to edit the showthread.php
__________________
If you need custom work done please use Dirt RIF CustUmz
Reply With Quote
Reply


Tags
database, delete, query, remove, table


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 10:20.

Layout Options | Width: Wide Color: