dhtmlxScheduler table update

Does anyone know how I can perform a custom update like I’m trying to do below OR is there a way to set labels.section_custom with a predefined value and make it read only or hidden?

$conn = new SchedulerConnector($res);

$sql = “SELECT * FROM events WHERE details = '”.$_SESSION[‘MM_Username’]."’";
$conn->sql->attach($sql,“UPDATE events SET details=’”.$_SESSION[‘MM_Username’]."’ WHERE event_id={id}");

You are going in correct direction, the above code has only one small typo

//first parameter is an operation type $conn->sql->attach("UPDATE","UPDATE `events` SET details='".$_SESSION['MM_Username']."' WHERE event_id={id}");

Thank you for your prompt reply, however, your suggested solution shown below does not work for me.

$conn->sql->attach(“UPDATE”,“UPDATE events SET details=’”.$_SESSION[‘MM_Username’]."’ WHERE event_id={id}");

Although $_SESSION has a result on other areas of the program (i.e., my SQL Statement), I’ve substituted a hard coded value to no avail. I’ve also tried the below solution which appears not to get triggered:

$res=mysql_connect("myservername ", “myusername”, “mypassword”);

function [b]my_update/b{
global $conn;
$details = $data->get_value(“details”);
// $details="’".$_SESSION[‘MM_Username’]."’";
$conn->sql->query(“UPDATE events SET details=’{$details}’ where event_id={$id}”);
$data->success(); //if you have made custom update - mark operation as finished

$conn = new SchedulerConnector($res);

$sql = “SELECT * FROM events WHERE details = '”.$_SESSION[‘MM_Username’]."’";
//$conn->sql->attach(“UPDATE”,“UPDATE events SET details=’”.$_SESSION[‘MM_Username’]."’ WHERE event_id={id}");
$conn->sql->attach(“UPDATE”,“Update events set details=‘Secretary Western Knights #56’ where event_id={id}”);

Further, please see the below log file. Why does event_id come back as event_id => 1365530635272 when the value in the database for event_id is 1261152085


Log started, 09/04/2013 11:04:00

DataProcessor object initialized
1365530635272_start_date => 2013-04-12 15:05
1365530635272_end_date => 2013-04-12 15:10
1365530635272_text => New event
1365530635272_id => 1365530635272
1365530635272_event_name => test
1365530635272_details => test
1365530635272_!nativeeditor_status => inserted
ids => 1365530635272

Row data [1365530635272]
start_date => 2013-04-12 15:05
end_date => 2013-04-12 15:10
event_name => test
event_id => 1365530635272
details => test
!nativeeditor_status => inserted

INSERT INTO events(start_date,end_date,event_name,details) VALUES (‘2013-04-12 15:05’,‘2013-04-12 15:10’,‘test’,‘test’)

Edit operation finished
0 => action:inserted; sid:1365530635272; tid:1261152085;
Done in 1.0140130519867s

Log started, 09/04/2013 11:04:03

SELECT * FROM events WHERE ( details = ‘Secretary Western Knights #56’)
Done in 0.4634530544281s

According to the log - you have added new event, which have issued INSERT operation ( INSERT custom sql action, beforeInsert events, etc) - so it doesn’t triggered the updated logic.

The “1365530635272” is valid unique id which is generated by client side ( it is expected that it will be replaced by the DB’s id ) - do you have event_id in table as autoincrement ?

Yes, it’s auto incremented. I’m using the database provided in your downloaded package. Can you provide a sample of doing a simple update while creating an event? I need to update a field with a session variable when an event is created using perhaps the “beforeUpdate”. Your tools are awesome! but I need to understand how I can refer to the record_id. I’ve researched your knowledge base extensively…for days; but it’s lacking real-life php/mysql examples of a simple update.

Once I have an example, I feel that I’d be able to many things with dhtmlxgrid and dhtmlxScheduler.

Yes, it’s auto incremented.
Please double-check it. The above situation is looks exactly the same as possible issue with non-autoincrement ids. ( also it can be sign of overflowing auto-id counter, but it must not be actual for newly created table )

To add SESSION data for new event, you can have on server side

[code] require_once(’…/…/…/…/connector-php/codebase/scheduler_connector.php’);
include (’…/…/common/config.php’);

$scheduler = new schedulerConnector($res, $dbtype);
    function insert_session($action){
        $action->add_field("user_id", $_SESSION["userid"]);
$scheduler->event->attach("beforeInsert", "insert_session");

Above code was tested locally.
It will add one more field for insert operation.

If you need more complex customization you can use

function insert_session($action){ global $scheduler; // reference to connector object $scheduler->sql->query("INSERT ...custom sql..."); $scheduler->success($scheduler->sql->get_new_id()); }

Thank you so much for your help and professionalism. You truly understood my problem and took the time to provide the best solution. /G\