fetching from the database (Scheduler + yii)

I use the scheduler in my yii project. Standard configuration connection to the Events table selects all events from the database. I need to be more flexible and to give only those events in which the user_id matches id of the current user… How should I do in this situation? Very need help! :neutral_face:

Hi,
if you use dhtmlxConnector, check this article docs.dhtmlx.com/connector__php__filtration.html

now im using JSONSchedulerConnector

i created actionScheduler_data() in my controller and it works for all events, but method “filter” not worked :frowning:

public function actionScheduler_data() { $dbtype = "MySQL"; $res=mysql_connect("localhost","root","");// db connection mysql_select_db("db"); $scheduler = new JSONSchedulerConnector($res, $dbtype); $scheduler->filter("worker", User::model()->findByPk(Yii::app()->user->id)); $scheduler->render_table("events","event_id","start_date,end_date,event_name,worker"); }

realy need support mates!

The filtering workd with primitive values, not with objects.
This line seems to return a instance of the logged in user
User::model()->findByPk(Yii::app()->user->id)
yiiframework.com/doc/api/1.1 … yPk-detail

If the event stores ids of the users they assigned to, probably the filter should look like this

$scheduler->filter("worker", Yii::app()->user->id);

i edit it…

but events not loaded… if i created event i see

  Fatal error: Call to undefined method JSONSchedulerConnector::filter() in C:\OpenServer\domains\root\protected\controllers\EventsController.php on line 

in side SchedulerConnector and extendeds classes i not see method filter() :\

i find microlib npmjs.org/package/simple-json-filter what do you think if I can integrate it with the help of scheduler.config.parse() method in js initialize?

sorry for bad eng! :unamused:

public function actionScheduler_data()
{
$dbtype = “MySQL”;
$res=mysql_connect(“localhost”,“root”,"");// db connection
mysql_select_db(“db”);
$currentUser = Yii::app()->user->id;
$company = $currentUser->company;
//$list = new JSONOptionsConnector($res, $dbtype);
//$list->render_table(“types”,“typeid”,“typeid(value),name(label)”);
$scheduler = new JSONSchedulerConnector($res, $dbtype);
//$scheduler->set_options(“type”, $list);
//$scheduler->filter(“worker”, User::model()->findByPk(Yii::app()->user->id));
$scheduler->filter(“company”, $company);
$scheduler->render_table(“events”,“event_id”,“start_date,end_date,event_name,company”);
}

If issue still occurs - please try to update the php codebase from here

github.com/dhtmlx/connector-php

Thank you S.

it work! :wink: