Hi Stanislav,
Be patient with me, i’me here again but with a partial success.
i succeded to enable PDO support, downloading the two necessary dll and simply copying them, without any installation, in \usr\local\extension in the web server.
Now the grid is populated with my data as i expected, but this was only the first step. Now i’d like to be able to update/insert/delete rows in my grid and, of course, in the DB.
I tried to adapt another example “update_names.php” and this is now my code:
index.html
Deve FUNZIONARE
<link rel='STYLESHEET' type='text/css' href='dhtmlxGrid/codebase/dhtmlxgrid.css'>
<link rel="stylesheet" type="text/css" href="dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script src='dhtmlxGrid/codebase/dhtmlxcommon.js'></script>
<script src='dhtmlxGrid/codebase/dhtmlxgrid.js'></script>
<script src='dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js'></script>
<script src='dhtmlxDataConnector/codebase/connector.js'></script>
<script src='dhtmlxGrid/codebase/dhtmlxgridcell.js'></script>
<p><a href="javascript:void(0)" onclick="mygrid.addRow((new Date()).valueOf(),[0,'','','',false,'na',false,''],mygrid.getRowIndex(mygrid.getSelectedId()))">Add row</a></p>
<p><a href="javascript:void(0)" onclick="mygrid.deleteSelectedItem()">Remove Selected Row</a></p>
connector_Access.php
<?php
require("dhtmlxConnector/codebase/grid_connector.php");
require("dhtmlxConnector/codebase/db_pdo.php");
$res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db\db_dati.mdb");
$grid = new GridConnector($res,"PDO");
$grid->render_table("utenti_bak","n_prod_id","n_prod_id,s_prod_name,f_prod_price,n_prod_qty,s_prod_total");
?>
update_names.php
<?php
//code below is simplified - in real app you will want to have some kins session based autorization and input value checking
error_reporting(E_ALL ^ E_NOTICE);
//include db connection settings
require("dhtmlxConnector/codebase/grid_connector.php");
require("dhtmlxConnector/codebase/db_pdo.php");
$res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db\db_dati.mdb");
$grid = new GridConnector($res,"PDO");
function add_row(){
global $newId;
$sql = "INSERT INTO utenti_bak(s_prod_name,f_prod_price,n_prod_qty,s_prod_total)
VALUES ('".addslahses($_GET["s_prod_name"])."',
'".$_GET["f_prod_price"]."',
'".$_GET["n_prod_qty"]."',
'".$_GET["s_prod_total"]."')";
$res = mysql_query($sql);
//set value to use in response
$newId = mysql_insert_id();
return "insert";
}
function update_row(){
$sql = "UPDATE utenti_bak s_prod_name='".addslashes($_GET["s_prod_name"].)"',
f_prod_price= '".$_GET["f_prod_price"]."',
n_prod_qty= '".$_GET["n_prod_qty"]."',
s_prod_total= '".$_GET["s_prod_total"]."'
WHERE n_prod_id=".$_GET["n_prod_id"];
$res = mysql_query($sql);
return "update";
}
function delete_row(){
$d_sql = "DELETE FROM utenti_bak WHERE n_prod_id=".$_GET["n_prod_id"];
$resDel = mysql_query($d_sql);
return "delete";
}
//include XML Header (as response will be in xml format)
header("Content-type: text/xml");
//encoding may differ in your case
echo('<?xml version="1.0" encoding="iso-8859-1"?>');
$mode = $_GET["!nativeeditor_status"]; //get request mode
$rowId = $_GET[“n_prod_id”]; //id or row which was updated
$newId = $_GET[“n_prod_id”]; //will be used for insert operation
switch($mode){
case “inserted”:
//row adding request
$action = add_row();
break;
case “deleted”:
//row deleting request
$action = delete_row();
break;
default:
//row updating request
$action = update_row();
break;
}
//output update results
echo “”;
echo “”;
echo “”;
?>
In this last script, that’s the problem, is enough to change the fields name or is necessary to change also the functions “mysql_query” and “mysql_insert_id” with other specific functions that i don’t know and i didn’t find in the examples ?
Many many thanks