PDA

View Full Version : Cron job to change database entry?


Desmo
11-11-2011, 11:33
Hi clever programmer types :D

I'm setting up some software at work to make our workflow a little smoother, quicker and more automated. I'm using vtiger open source software to do this.

I've currently got a workflow setup so that when an "Email Supplier" tickbox is true, that supplier is emailed the quote. Trouble is, the supplier gets emailed every time the quote is modified and saved. This workflow is run with a cron jon.

What I'd like to do is have the "Email Supplier" tickbox set to false each time the cron job is run. I've found the entry in the sql database but not sure what to do next.

leowyatt
11-11-2011, 11:41
I would write a php script to loop through the database and set the field to false :)

Desmo
11-11-2011, 12:10
Great....so how would I do that? :p

leowyatt
11-11-2011, 12:14
to MSN!

http://ihatepeacocks.com/resources/batman-old-school-logo-tv-series-gif.gif

Mark
12-11-2011, 00:52
Kapow? ;)

No need for a loop for this by the way - a single update would do it, which you can do just about any way you want. :)

Garp
12-11-2011, 21:04
As Mark suggests, should be as simple as running something like:

UPDATE table SET field = FALSE WHERE somecondition=something;

If you're just trying to do the entire table you can ignore everything from WHERE (but don't forget the ';' mark)

leowyatt
13-11-2011, 13:11
I think we've almost cracked it :) I suggested a loop because I didn't know his db structure

Blighter
13-11-2011, 16:23
to MSN!

http://ihatepeacocks.com/resources/batman-old-school-logo-tv-series-gif.gif

That cracked me up ;D

Desmo
19-11-2011, 12:26
Just thought I'd post up that with loads of help from Leo, I got all of this working spot on :)
The database changes work and it's also tied in to the current corn job so runs when it should.