Rendering table from Sqlite Database

Hi I would like to use a sqlite database in scheduler object.
Could you give me some help?

For example how can I get the events from Sqlite table?

I open a database with;

if(!($db=new SQLite3('sqlite/agenda', '0666')))
{
	echo "<h2>".$TEXT['phonebook-error']."</h2>";
	die();
}

I fetch result with:

$result_ed = $db->query("SELECT Paziente, DataNasc, CodFisc, Indirizzo, Comune, Note FROM dent_x_pazienti WHERE IdPaziente = ".$id.";"); $row_ed=$result_ed->fetchArray(SQLITE3_ASSOC);

It works.

But the difficult thing is to load the event in scheduler:

[code]scheduler.load(“php/events.php”);

	//scheduler.init('scheduler_here',new Date(2009,10,1),"month");
	scheduler.init('scheduler_here',null,"week");
	scheduler.setLoadMode("week")
	
	var dp = new dataProcessor("php/events.php");
	dp.init(scheduler);[/code]

on server side

$data = array(); while ($rec = $res->fetchArray(SQLITE3_ASSOC)) $data[] = $rec; //output json echo json_encode($data);

on client side

scheduler.load("php/events.php", "json");

Also, you can check php connectors they can be used with SQLite
dhtmlx.com/docs/products/dhtmlxC … ndex.shtml

I can’t solve my problem.
My event_sqlite.php file is:

[code]<?php

require("../../_dhtmlxConnector/codebase/scheduler_connector.php");
require("../../_dhtmlxConnector/codebase/data_connector.php");
include ("../../_dhtmlxConnector/codebase/db_sqlite3.php");

if(!($db=new SQLite3('../sqlite/agenda', '0666')))
{
	die($sqliteerror);
}

$scheduler = new SchedulerConnector($db, "SQLite");
$scheduler->enable_log("/opt/log.txt",true);

$scheduler->render_table("dent_events","event_id","start_date, end_date, event_name, x_pazienti_id, x_fatture_id");

// $result = $db->query(" SELECT event_id, start_date, end_date, event_name, x_pazienti_id, x_fatture_id
// FROM dent_events;");

// $data = array();
// while ($rec = $result->fetchArray(SQLITE3_ASSOC)) $data[]=$rec;
// echo json_encode($data);

?>

[/code]

Database format is SQLite 3.

My client call is:


....
//appunti			  
//		scheduler.load("php/events.php");
		scheduler.load("php/events_sqlite.php", "json");

		//scheduler.init('scheduler_here',new Date(2009,10,1),"month");
		scheduler.init('scheduler_here',null,"week");
		scheduler.setLoadMode("week")
		
//appunti			  
//		var dp = new dataProcessor("php/events.php");
		var dp = new dataProcessor("php/events_sqlite.php","json");
		dp.init(scheduler);

.........

There’s a error 404"Object not found" in my firebug console window.

Can you help me ?

Help !!

Error 404 does mean that you have provided invalid url somewhere in the html page - check that php/events_sqlite.php is valid relative path to the php feed, try to open it directly in browser.

Ok, I forgot to write the extension of events.php file.
Now it’s ok.

The right code is:

[code]<?php

//$scheduler->enable_log("log.txt",true);
require ("../../_dhtmlxConnector/codebase/db_sqlite3.php");	
require ("../../_dhtmlxConnector/codebase/data_connector.php");	
require ("../../_dhtmlxConnector/codebase/scheduler_connector.php");	

if(!($db=new SQLite3("../sqlite/agenda", "0666")))
{
	echo "<h2>"."Errore"."</h2>";
	die();
}

$list = new OptionsConnector($db);
$list->render_table("dent_x_pazienti","IdPaziente","IdPaziente(value),Paziente(label)");

$scheduler = new schedulerConnector($db,"SQLite3");
$scheduler->set_options("dent_x_pazienti", $list);
$scheduler->render_table("dent_events","event_id","start_date,end_date, event_name, x_pazienti_id, x_fatture_id");

?>[/code]

But another problem is that list option is empty mybe the render_table method is incorrect?

Thank you !

Server side code looks fine, can you provide client side lightbox config ?

[code] scheduler.config.lightbox.sections=[
{name:“paziente”, options: scheduler.serverList(“dent_x_pazienti”), map_to:“x_pazienti_id”, type:“combo”,
image_path: “…/_dhtmlxCombo/codebase/imgs/”, filtering: true, /script_path: “php/complete.php”,/ cache: false},
{name:“description”, height:20, map_to:“text”, type:“textarea”, focus:true},
// { name:“Fattura”, map_to:“fattura”, type:“checkbox”, checked_value: “fattura”, unchecked_value: “”},
{name:“time”, height:72, type:“time”, map_to:“auto”}
]

//appunti
scheduler.load(“php/events2.php”);[/code]

Ok, the problem mybe is in the complete.php file
Right ??

[code]<?php
header(“Content-type:text/xml”);
ini_set(‘max_execution_time’, 600);
require_once(’…/…/_dhtmlxScheduler/common/config.php’);
print("<?xml version=\"1.0\"?>");

$link = mysql_pconnect($server, $user, $pass);
$db = mysql_select_db ($db_name);

if (!isset($_GET["pos"])) $_GET["pos"]=0;


getDataFromDB($_GET["mask"]);
mysql_close($link);



//print one level of the tree, based on parent_id
function getDataFromDB($mask){

	// $sql = "SELECT DISTINCT Paziente FROM x_pazienti Where Paziente like '".mysql_real_escape_string($mask)."%'";
	 $sql = "SELECT Paziente FROM dent_x_pazienti Where Paziente like '".mysql_real_escape_string($mask)."%'";
	 $sql.= " Order By Paziente LIMIT ". $_GET["pos"].",20";

	if ( $_GET["pos"]==0)
		print("<complete>");
	else
		print("<complete add='true'>");
	$res = mysql_query ($sql);
	if($res){
		while($row=mysql_fetch_array($res)){
			print("<option value=\"".$row["IdPaziente"]."\">");
			print($row["Paziente"]);
			print("</option>");
		}
	}else{
		echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
	}
	print("</complete>");
}

?>[/code]

In config you have the next

   image_path: "../_dhtmlxCombo/codebase/imgs/", filtering: true, /*script_path: "php/complete.php",*/ cache: false},

script_path is commented
If this is the correct code - the combo will not try to load data from server side at all, which mean error 404 is not related to scheduler’s configuration and combo at all.

Both client side and server side code looks valid, are you sure that error 404 is triggered by scheduler’s code ?

I do not have the Error 404. Now it’s ok. I’ve another problem: list option in combo is empty (it doesn’t render the table dent_pazienti.

The code is:

{name:"paziente", options: scheduler.serverList("dent_x_pazienti"), map_to:"x_pazienti_id", type:"combo", image_path: "../_dhtmlxCombo/codebase/imgs/", filtering: true, cache: false},

without

/script_path: “php/complete.php”,/

The list come from
options: scheduler.serverList(“dent_x_pazienti”)

right?