Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by diego on Dec 17, 2009 07:54
open dhtmlx forum
add events with postgresql

hi.

db_postgre.php'm editing the file and not see the function to insert data and I would like to add events directly into the database.

I wonder what that function is done or should I use to add modify and delete data with postgresql

thank you very much for your time and collaboration
Answer posted by Alex (support) on Dec 17, 2009 08:31

Hello,

you can use DataProcessor to send changes in the scheduler to the server. In case of using connectors events will be inserted and deleted automatically. 

Please, see the sample:

dhtmlxScheduler/samples/01_initialization_loading/05_loading_mysql.html

Answer posted by diego on Dec 17, 2009 14:14
hi again

I use exactly the same example and I have loaded the data in postgresql but when I insert or other operciones ised xml I get errors and I did not record the data

My pages are like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title></title>
</head>
    <script src="../componentes/codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
    <script src="../componentes/sources/locale_es.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="../componentes/codebase/dhtmlxscheduler.css" type="text/css" title="no title" charset="utf-8">
 
     
<style type="text/css" media="screen">
    html, body{
        margin:0px;
        padding:0px;
        height:100%;
        overflow:hidden;
    }     
</style>
 
<script type="text/javascript" charset="utf-8">
    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:true},
            {name:"location", height:43, type:"textarea", map_to:"details" },
            {name:"time", height:72, type:"time", map_to:"auto"}
        ]
        scheduler.config.first_hour=4;
        scheduler.locale.labels.section_location="Location";
        //scheduler.config.details_on_create=true;
        //scheduler.config.details_on_dblclick=true;
 
 
     
        scheduler.init('scheduler_here',null,"month");
        scheduler.load("events.php?uid="+scheduler.uid());
         
        var dp = new dataProcessor("php/events.php");
        dp.init(scheduler);
 
    }
</script>
 
<body onload="init();">
    <div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
        <div class="dhx_cal_navline">
            <div class="dhx_cal_prev_button">&nbsp;</div>
            <div class="dhx_cal_next_button">&nbsp;</div>
            <div class="dhx_cal_today_button"></div>
            <div class="dhx_cal_date"></div>
            <div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
            <div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
            <div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
        </div>
        <div class="dhx_cal_header">
        </div>
        <div class="dhx_cal_data">
        </div>         
    </div>
</body>


and the page of events.php is:

<?php
    //session_start();
    include ('../componentes/codebase/connector/scheduler_connector.php');
    include_once('../componentes/codebase/connector/db_postgre.php');
    require_once("../componentes/comunicacion.inc");
   
    global $DB_SERVER,$DB_PORT,$DB_NAME,$DB_USER,$DB_PASSWORD;
  $res = pg_connect("host=$DB_SERVER port=$DB_PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASSWORD");
    //$res=mysql_connect($server, $user, $pass);
    //mysql_select_db($db_name);
     
    $scheduler = new schedulerConnector($res,"Postgre");
    //$scheduler->enable_log("log.txt",true);
    $scheduler->render_table("eventos","id_evento","start_date,end_date,evento_nombre,detalles");
?>

and the table in postgresql is this:

CREATE TABLE eventos
(
  id_evento character varying NOT NULL,
  start_date timestamp without time zone,
  end_date timestamp without time zone,
  evento_nombre character varying,
  detalles character varying,
  CONSTRAINT eventos_pkey PRIMARY KEY (id_evento)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE eventos OWNER TO postgres;

please help me
Answer posted by Alex (support) on Dec 18, 2009 02:05

Hello,

table field that corresponds to event id should be generated automatically. It means that you should define sequence for it.

Answer posted by Alex (support) on Dec 18, 2009 02:16

The example:

CREATE SEQUENCE eventos_id_seq;

CREATE TABLE eventos
(
  id_evento INTEGER DEFAULT NEXTVAL('eventos_id_seq'),
  start_date timestamp without time zone,
  end_date timestamp without time zone,
  evento_nombre character varying,
  detalles character varying,
  CONSTRAINT eventos_pkey PRIMARY KEY (id_evento)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE eventos OWNER TO postgres;




Answer posted by diego on Dec 18, 2009 06:29
hi

I wonder whether you can control the insertion of each event is sent fields know that when you save, edit or delete because I associate some events because I have certain users in postgresql stored procedures
Answer posted by Alex (support) on Dec 18, 2009 06:48

It is possible to define custom insert, delete and update handlers. Please see details in the documentation:

http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxconnector:complex_updates

The full event list is http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxconnector:events_system