Hi all.
I want to do my custom update “beforeUpdate”.
I want select an actual value from DB table events and use it from UPDATE the table events.
I’m confuse.
Can you help me?
Hi all.
I want to do my custom update “beforeUpdate”.
I want select an actual value from DB table events and use it from UPDATE the table events.
I’m confuse.
Can you help me?
There is no special helpers for such use-case, you can use
$res = $scheduler->sql->query("SELECT ... ");
$data = $scheduler->sql->get_next($res);
It just wraps previously defined connection, and hides db specific commands ( you can use mysql_query or similar code directly, it will not differ )
I have this:
function myUpdate($action){
mysql_query("UPDATE events SET
event_name='{$action->get_value('event_name')}',
end_date='{$action->get_value('MY-PROBLEM')}',
WHERE event_id='{$action->get_value('event_id')}'");
$action->success();
}
$scheduler->event->attach("beforeUpdate",myUpdate);
I want get the value of MY-PROBLEM from an previous SQL SELECT.
For example:
function myUpdate($action){
mysql_query("SELECT MY-PROBLEM FROM events WHERE event_id='{$action->get_value('event_id')}'"); // it's wrong?
mysql_query("UPDATE events SET
event_name='{$action->get_value('event_name')}',
end_date='{$action->get_value('MY-PROBLEM')}',
WHERE event_id='{$action->get_value('event_id')}'");
$action->success();
}
$scheduler->event->attach("beforeUpdate",myUpdate);
Can you help me
Thank you.
Sondra
Probably the next will work
function myUpdate($action){
$res = mysql_query("SELECT MY-PROBLEM FROM events WHERE event_id='{$action->get_value('event_id')}'");
$data = mysql_fetch_array($res);
$action->set_value("MY_PROBLEM", $data[0]);
... your old code after that point ....