Page 1 of 1
cron and browser support for php
Posted: Tue Feb 19, 2013 12:40 pm
by tec-linux
I have a php script that uses an html form action get in order to pass parameters on the url line to my php. I would like to be able to also kick the php off from cron from time to time. And I would like to use the same php script rather than support 2 that do the same database updates. I know that I have the php command but no lynx. Does php support passing parameters that in a browser invokation look like
http://www.ethics.state.tx.us/webupdate ... d=Continue
Thanks,
Patty
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 3:28 pm
by Christopher
Yes, you can pass parameters in the URL using the GET HTTP method or send them by POST commonly used for forms. You can also run php from the command line interface.
With crons, typically the cron runs regularly and the PHP script would add entries into a database that would then be processed. I would be concerned about security if you allowed a PHP script to start a cron based on parameters.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 3:43 pm
by califdon
I would also have concern about any code that drives a database update without any human input. There certainly are some circumstances where that is appropriate, such as entering hourly temperature readings, etc., but whenever I see this question raised in a forum, I am suspicious, because I have seen it misused in some instances. For example, I have seen someone who wanted to run a process that would periodically calculate totals from other data and insert it into the database, which is completely unnecessary; calculated values like that are part of the query, not something to be calculated and stored and updated. Your application may indeed require timed updates, but since you didn't provide enough details to judge that, I thought I would just make this comment.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 4:01 pm
by tec-linux
We have 2 databases and they tend to get out of sync. One database is used when outside folks do queries. The other database is protected from the outside and most users cannot access the database. The php script was a way to sync up a couple of important fields (info_only, ie don't use for outside queries), just copy what is in the internal database to the public query database. These info_only fields are sometimes manually updated and the public query database gets out of sync.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 4:22 pm
by califdon
OK, that may be necessary, then, although my first thought is that, rather than dealing with the symptoms, you might do better to deal with the underlying problem, which seems to be that one database doesn't always get updated promptly. But that's a different issue than you asked about, so I'll shut up.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 4:46 pm
by requinix
Is the public database read-only? How about replication?
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 5:08 pm
by tec-linux
the public database has cfm (coldfusion) queries that are read only that the public uses. The php script of course would be run in house and would be updating.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 6:41 pm
by Christopher
Sounds like a job for replication where the public database a slave and the private one a master.
Re: cron and browser support for php
Posted: Tue Feb 19, 2013 9:41 pm
by califdon
Yup, that would be a far better approach. Possibly even just regular backups, depending on how often these manual updates are occurring. Allowing such manual updates is probably a bad policy, though, for several reasons, so if there's any possibility of getting administrative control of that activity, I would recommend that you look into that. Perhaps if you had a nice custom update screen that was even easier to use than PHPmyAdmin or whatever control panel they may be using, the person(s) who are making these updates would actually prefer to use the custom script, which could then properly update both databases.