How to use custom sql to work with events based on user id?

Hi
I have this scheduler which is supposed to show events for specific users, restricted on user id stored in $_SESSION[‘id’].
I am using the following code to display the events and this is working but I can’t create/edit events. I need to write the user id in the table.

$scheduler->render_sql(“SELECT * from events WHERE ev_user_id = 1”, “event_id”,“start_date,end_date,event_name,lesson_id,ev_user_id”);

Thanks in advance for any help

Grab the latest connector from github
github.com/DHTMLX/connector-php

With updated files you can use

$scheduler->filter("ev_user_id", $_SESSION['id']); $scheduler->render_table("events", "event_id","start_date,end_date,event_name,lesson_id,ev_user_id");

which will work for both data loading and data saving

Also, there are some other solutions
docs.dhtmlx.com/doku.php?id=dhtm … ral_tables

I’ve downloaded the new connector and I’m using connector-php-master\codebase\scheduler_connector.php and the code above but it seems that this doesn’t change a thing. It creates a new record in the table with the ev_user_id = 0. It displays the events correctly but it doesn’t create/edit. Can you tell me more about the other options docs.dhtmlx.com/doku.php?id=dhtm … ral_tables because I couldn’t find much documentation on this subject (code for other operations - i.e. update/insert/delete) ?

Many thanks for replies

Please check in scheduler’s package samples\08_shared_events\events.php
This code implements the similar scenario it select data from DB for specific user only, and uses the server side events to enforce userId value for all data saving operations.

Thanks Stanislav, you’re a life saver :slight_smile: . I found the solution

Hi
How to wrie render_complex_sql, its not working, can u give one example,like u gave above for render_sql

render_complex_sql has the same parameters as render_sql command and can be used in the same way.

If your version of connector doesn’t support this command - just update connector files from github.
github.com/dhtmlx/connector-php