Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2006, 07:12 PM
photongbic photongbic is offline
 
Join Date: Oct 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP cron to access events and user data

I am trying to access the event and user tables through a PHP cron job and being a complete newbie, I am having issues!!!

I downloaded the tables as CSV files to get their field names and layout. I then used the following to access the data on my vb3.5.5 forum:

PHP Code:
<?php 
include('./global.php'); 

$events $db->query_read("SELECT UNIX_TIMESTAMP() AS calendarid, dateline_from, title, lv_vb_eventforums_threadid, customfields 
                           FROM event
                           WHERE dateline_from > UNIX_TIMESTAMP()
                           ORDER BY dateline_from"
);
That didn't work (global.php errors), so let's try copying from some other cron jobs:

PHP Code:
?php
require_once(DIR '/includes/functions_calendar.php');

$timenow TIMENOW;

/
$events $vbulletin->$db->query_read("
  SELECT event.calendarid, dateline_from, event.title, lv_vb_eventforums_threadid, customfields, 
  FROM " 
TABLE_PREFIX "event AS event
  WHERE dateline_from >= 
$timenow AND event.calendarid = 1
  ORDER BY dateline_from"
); 
Nope, no such luck!
Fatal error: Call to a member function on a non-object in .../includes/cron/events.php on line 16
Line 16 is the SELECT statement.

OK, I know I'm clueless but can you help me get this working?
When do you use $vbulletin->$db->query_read versus $db->query_read?
Why do the fields names change (event.title versus title)?
How do you read data from a table?

I have spent DAYS going through all the keyword searches I can think of and nothing conclusive. When I get this thing working, I am going to post an "Idiots Guide to Reading vBulletin Databases".

Thnaks in advance for any help you can offer me!!!!!
Reply With Quote
  #2  
Old 08-24-2006, 07:42 PM
bairy bairy is offline
 
Join Date: Oct 2005
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's $vbulletin->db->query_read (there's no $ on the db part)
Reply With Quote
  #3  
Old 08-24-2006, 11:28 PM
photongbic photongbic is offline
 
Join Date: Oct 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the help...don't know how I missed that one :-(

Now I get the following:
Quote:
SELECT event.calendarid, dateline_from, event.title, lv_vb_eventforums_threadid, customfields,
FROM event AS event
WHERE dateline_from >= 1156455695 AND event.calendarid = 1
ORDER BY dateline_from;

MySQL Error : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM event AS event
WHERE dateline_from >= 1156455695 AND eve
Error Number : 1064
I tried several different combinations but no luck.

The CSV file shows the field names as calendarid, dateline_from, title, lv_vb_eventforums_threadid and customfields. But changing the field names doesn't seem to help.

Thoughts?

Also, how do you know which field names to use?
Reply With Quote
  #4  
Old 08-25-2006, 07:51 AM
bairy bairy is offline
 
Join Date: Oct 2005
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I re-read the first post and it said you're trying to access the event and user tables. Which fields from which tables are you trying to access?
Reply With Quote
  #5  
Old 08-25-2006, 08:28 AM
photongbic photongbic is offline
 
Join Date: Oct 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bairy
I re-read the first post and it said you're trying to access the event and user tables. Which fields from which tables are you trying to access?
I decided I was having enough problems with the event table that I might want to just work on it first. The nightmare of the user table has yet to begin.

Quote:
SELECT event.calendarid, dateline_from, event.title, lv_vb_eventforums_threadid, customfields,
FROM event AS event
WHERE dateline_from >= 1156455695 AND event.calendarid = 1
ORDER BY dateline_from;

MySQL Error : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM event AS event
WHERE dateline_from >= 1156455695 AND eve
Error Number : 1064
Any thoughts on the above error message?
Reply With Quote
  #6  
Old 08-26-2006, 08:34 AM
bairy bairy is offline
 
Join Date: Oct 2005
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No idea, it looks fine and works in my phpmyadmin.
The reason I asked was because I'm not certain over the way the sql has been put together, which means I can't figure out why it's erroring. I know it can be picky about the smallest of details, so I was wondering what the entire query was to do so I could construct one for you.
Reply With Quote
  #7  
Old 08-26-2006, 01:46 PM
photongbic photongbic is offline
 
Join Date: Oct 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bairy
No idea, it looks fine and works in my phpmyadmin.
The reason I asked was because I'm not certain over the way the sql has been put together, which means I can't figure out why it's erroring. I know it can be picky about the smallest of details, so I was wondering what the entire query was to do so I could construct one for you.
I want to read the event database (where the events are curent or in the future) from calendar "1". I am only interested in calendarid, dateline_from, title, lv_vb_eventforums_threadid, customfields. I guess I could use an "*" instead of specifying the fieldnames but doesn't that take more time and waste memory? Maybe I am just over thinking it!

Thanks!
Reply With Quote
  #8  
Old 08-26-2006, 02:10 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First of all, you are calling the table AS event.. Then you are only prefixing a few columns with event.. Get rid of the whole AS event bit as well and any prefixes used. That is not needed with a single table call and confuses things.

The error message is most likely refering to your last column call. Get rid of the final comma before FROM.

PHP Code:
 customfields
Is the a scheduled task cron or a server cron?
Reply With Quote
  #9  
Old 08-26-2006, 09:02 PM
bairy bairy is offline
 
Join Date: Oct 2005
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I noticed the unnecessary 'event's, I was gonna tackle them in any rewrite.

And yes, the error is likely from that comma. It's always the tiny symbols you don't notice that cause the most trouble eh.


In case it's not clear, this is the tidy rewrite of that code:
Code:
SELECT calendarid, dateline_from, title, lv_vb_eventforums_threadid, customfields
FROM event
WHERE dateline_from >= 1156455695 AND calendarid = 1
ORDER BY dateline_from
Reply With Quote
  #10  
Old 08-28-2006, 03:01 AM
photongbic photongbic is offline
 
Join Date: Oct 2005
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You guys rock! Thanks, the fog is lifting.

Quote:
Is the a scheduled task cron or a server cron?
It will be a scheduled task cron job that runs once a night at off hours to seperate the calendar events so we can display our membership and events by county. Hopefully making it easier for our members to find each other and the surrounding events.

Thanks again!
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 09:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04590 seconds
  • Memory Usage 2,260KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete