Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by jennifer on Jun 16, 2009 10:14
open dhtmlx forum
adding and deleting data to db using connector and dataprocessor

Okay, I am relatively new so excuse my inexperience. I have the scheduler up and running and am retrieving information from a MySql database into the scheduler. I am missing the link as to how to do an update so that I can either add, change or delete an event. I understand the part about retrieving the data but I am missing the link as to how to get it back into the db. Just a sample would help. I use a php script (events.php) to do the retrieve and display... where do I go from here.

Thanks so much in advance for all you help.


Jen
Answer posted by Support on Jun 17, 2009 01:58
If you are using connectors, you just need to add next two lines to client side code


var dp = new dataProcessor("events.php");
dp.init(scheduler);


After such update - any changes made to event on client side will be synced with DB ( you need not any additional code on server side ) 

>> Just a sample would help.
sample_db.html, which is included in dhtmlxscheduler package, demonstrates such use-case
Answer posted by jennifer on Jun 18, 2009 10:36
okay... but nothing as far as the db is concerned is syncing with the server.  As soon as I navigate away from the scheduler after making changes to an event and saving them they appear on the page.  However when I leave the scheduler and return they are not there.  Furthermore they are not being updated in the db.  Here is my events.php code.  Maybe I am just not getting it or I need to invoke some method after a specific event?  I have reviewed
sample_db.html and in fact that is how I  got it to retrieve info from the db. 


<?php
    include ('../codebase/connector/scheduler_connector.php');

    // Connect to DB
    $user = "#######";
    $pass = "###########";
    $host = "##########";
    $db_name = "#####";

    $res=mysql_connect($host,$user,$pass);

    mysql_select_db($db_name);

    $scheduler = new schedulerConnector($res);
    $scheduler->enable_log("scheduler_log.txt",true);
    $scheduler->render_table(
        "calendar_events",
        "cal_event_id",
        "cal_event_start,cal_event_end,cal_event_title,cal_event_desc, cal_event_priority"
    );
?>

and the my init code is:

function init() {

        scheduler.config.xml_date="%Y-%m-%d %H:%i";
        scheduler.config.lightbox.sections=[
            {name:"description", height:130, map_to:"text", type:"textarea" , focus:tr
            {name:"location", height:43, type:"textarea", map_to:"details" },
            {name:"time", height:72, type:"time", map_to:"auto"}
        ]
        scheduler.config.first_hour=8;
        scheduler.locale.labels.section_location="Location";
        scheduler.config.details_on_create=true;
        scheduler.config.details_on_dblclick=true;

        scheduler.init('scheduler_here',null,"week");
        scheduler.load("events.php?uid="+scheduler.uid());

        var dp = new dataProcessor("events.php")
        dp.init(scheduler);
    }
  

Thanks so much for your help.

Jen


Answer posted by Support on Jun 19, 2009 02:50
The code looks correct. Please check content of scheduler_log.txt , which will contain info about all data updating operation and detailed error info, in case of DB related errors.