View previous topic :: View next topic |
Author |
Message |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Thu Oct 05, 2006 12:32 am Post subject: Accessing mysql via dos |
|
|
This may be a daft question but to access your mysql data from a batch file would you just prefix the command with the mysql bin file?
To explain, I am trying to put together a batch that will run every 5 mins and read my database and output the number of users online and the last message posted and squirt it out to my LED display. I was going to do this from a web page then I realised I would have to have the page active all the time and do a meta refresh, much better then to have a scheduled job me thinks.
Hope this isn't too off topic for this forum.
thanks Paul |
|
Back to top |
|
|
Mikor -
Joined: 21 Aug 2006 Posts: 144 Location: Hull, England
|
Posted: Thu Oct 05, 2006 7:57 am Post subject: |
|
|
This is how I would do it:
"C:\Program Files\PHP5\php-cgi.exe" "C:\path\to\your\script.php"
Then just make the script do the database stuff _________________ Yarrt.com - Free Arcade
RypNet.co.uk - Online Game
MSN: michael_walker_2004 <at> hotmail <dot> com |
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Thu Oct 05, 2006 10:24 am Post subject: |
|
|
What a fantastic solution!
Thanks mate |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Oct 05, 2006 12:28 pm Post subject: |
|
|
Mikor wrote: | This is how I would do it:
"C:\Program Files\PHP5\php-cgi.exe" "C:\path\to\your\script.php"
Then just make the script do the database stuff |
It is even better to use php.exe instead of php-cgi.exe. Actually php.exe in the preconfigured package is the CLI version (Command Line Interface) version of PHP which is meant to be run without a web server and directly from the command line. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Thu Oct 05, 2006 2:00 pm Post subject: |
|
|
Thanks Aprelium :)
I have another quick question, i know how to display all my records from mysql DB table, but how to I display just the most recent one, all records have an ID number so I think I'm on the right track.
Paul |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Oct 05, 2006 4:41 pm Post subject: |
|
|
I use the command line method for my uptime scripts. It also runs my daily maintenance script but thats just a bat file, its not php unlike the uptime script. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Fri Oct 06, 2006 2:45 pm Post subject: |
|
|
That's the bugger, thanks aprelium! |
|
Back to top |
|
|
F.Boyce -
Joined: 11 Oct 2011 Posts: 2 Location: Madagascar
|
Posted: Fri Oct 14, 2011 2:27 am Post subject: Accessing mysql via dos |
|
|
can think of is when that table is the parent of another table and the child table wants, for some reason, to minimize the size of its FK to the parent
for example,
team_player teamid, playerid
team_player_roster teamid, playerid, startdate, enddate |
|
Back to top |
|
|
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
Posted: Sun Oct 23, 2011 2:37 am Post subject: |
|
|
Try this too:
SELECT COUNT(*) FROM Users_Table_Here WHERE user_online_flag = '1';
Assuming you have a 0/1 flag for the online status, but more likely there will be a date that you'll use there (i.e. last_action_time > " . (time()-1800) . ") will show users online in the last half hour if you're using PHP and the last_action)time is stored as a Unix timestamp. _________________ Audit the secure configuration of your server headers! |
|
Back to top |
|
|
|