myForm.save() with PDO

Hello,

i have a form and i want to update data in my DB with the form’s data.

But i have this error in my log :

[code]UPDATE LIBRARY.ART SET ARTNUM=‘XXXX’,ARTDEP=‘100’ WHERE ARTNUM=‘XXXX’

exception ‘Exception’ with message 'PDO - sql execution failed
Table ART de LIBRARY incorrecte pour cette opération.[/code]

But if i take this reques and i use it directly on the server, it works…

Here is my code :

form.html :

[code]

Test Formulaire
<link rel="stylesheet" type="text/css" href="dhtmlxForm/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css">

<script src="dhtmlxGrid/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<script src="dhtmlxForm/dhtmlxForm/codebase/dhtmlxcommon.js"></script>
<script src="dhtmlxForm/dhtmlxForm/codebase/dhtmlxform.js"></script>
<script src="dhtmlxForm/dhtmlxForm/codebase/ext/dhtmlxform_item_calendar.js"></script>
<script src="dhtmlxGrid/dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>
<link rel="stylesheet" type="text/css" href="dhtmlxGrid/dhtmlxCalendar/codebase/dhtmlxcalendar.css">
<link rel="stylesheet" type="text/css" href="dhtmlxGrid/dhtmlxCalendar/codebase/skins/dhtmlxcalendar_dhx_skyblue.css">
var myForm, formData; function doOnLoad() { formData = [ {type: "fieldset", name:"form", label:"Recherche d'article", list:[ {type: "input", name: 'ARTNUM', label: 'Article:', position: 'label-top',disabled:'', value:'', required:''}, {type: "input", name: 'ARTDEP', label: 'Stock reel:', position: 'label-top', width : 100}, {type:"button", name:"OK", width:150, value:"Valider"}, {type:"button", name:"Cancel", width:150, value:"Retour"}, ]}];
		myForm = new dhtmlXForm("form_container", formData);
		myForm.load("connection/pdo.php?id=XXXX");
		
		var dp = new dataProcessor("php/dataUP.php");
		dp.init(myForm);
		
		myForm.attachEvent("onButtonClick", function(name){
			window[name]();
		});
	}
	function OK() {
		myForm.save();
	}
	
	function Cancel(){
	
	}
	</script>
[/code]

dataUP.php :

[code]<?php
$options = array ();
$options[‘i5_naming’] = true ;
$options[‘i5_libl’] = array() ;
$options[‘DB2_ATTR_CASE’] = ‘UPPER’ ;

require_once ‘…/dhtmlxConnector/codebase/dataprocessor.php’;
require_once ‘…/dhtmlxConnector/codebase/form_connector.php’;
require_once ‘…/dhtmlxConnector/codebase/db_pdo.php’;

$ipa = ‘*LOCAL’ ;
$usr = ‘DB2USER’ ;
$pwd = ‘PWD’ ;

$cnx_db01 = new pdo(‘ibm:*LOCAL’, $usr, $pwd, $options);

$form = new FormConnector($cnx_db01,“PDO”);

$form->enable_log(“db.log”);

$form->render_table(“LIBRARY.ART”,“ARTNUM”, “ARTNUM, ARTDEP”);
?>[/code]

pdo.php :

[code]<?php
$options = array ();
$options[‘i5_naming’] = true ;
$options[‘i5_libl’] = array() ;
$options[‘DB2_ATTR_CASE’] = ‘UPPER’ ;

require_once ‘…/dhtmlxConnector/codebase/dataprocessor.php’;
require_once ‘…/dhtmlxConnector/codebase/form_connector.php’;
require_once ‘…/dhtmlxConnector/codebase/db_pdo.php’;

$ipa = ‘*LOCAL’ ;
$usr = ‘DB2USER’ ;
$pwd = ‘PWD’ ;

$cnx_db01 = new pdo(‘ibm:*LOCAL’, $usr, $pwd, $options);

$form = new FormConnector($cnx_db01,“PDO”);

$form->enable_log(“db.log”);
$sql =“SELECT ARTNUM, ARTDEP FROM LIBRARY.ART”;

$form->render_sql($sql, “ARTNUM”, “ARTNUM, ARTDEP”);

?>[/code]

Thanks for the help.

P.S : I want to use data of my DB in a label’s value, what should I write ?
If the name of my data is LABEL_K :

{type: "label", name: 'LABEL_K', label: '',position: 'label-top'},

But the label still empty with this code.

If running the same code against DB works correctly - the problem must be somewhere in PDO data driver. Sorry, I can’t help here.

If you do think that sql code must be different in your case - please provide details.

Hello
You can try the next code sample to set date from calendar to custom text item. You can try to customize it insteal of using labels:

[code]

Custom item var myForm, formData; function doOnLoad() { formData = [ {type: "myItem", name: "test", my_text: "This is custom item"}, {type: "calendar", dateFormat: "%Y-%m-%d %H:%i", name: "start_date", label: "Start Date"} ]; myForm = new dhtmlXForm("myForm", formData); myForm.setItemLabel("test", "Data last modified on "); myCalendar = myForm.getCalendar("start_date"); myCalendar.attachEvent("onClick", function(d){ var newDate = myCalendar.getFormatedDate("%Y-%m-%d %H:%i", d); myForm.setItemLabel("test", "Data last modified on "+newDate); });
	}
	dhtmlXForm.prototype.items.myItem = {
		render: function(item, data) {
			item._type = "myItem";
			item.appendChild(document.createElement("DIV"));
			item.lastChild.innerHTML = data.my_text;
			this._custom_inner_func(item);
			return this;
		},
		destruct: function(item) {
			this._custom_inner_func2(item);
			item.innerHTML = "";
		},
		enable: function(item) {
			item.lastChild.style.color = "black";
			item._is_enabled = true;
		},
		disable: function(item) {
			item.lastChild.style.color = "gray";
			item._is_enabled = false;
		},
		_custom_inner_func: function(item) {
			item.lastChild.onclick = function(){
				if (this.parentNode._is_enabled) alert("Hello!")
			}
		},
		_custom_inner_func2: function(item) {
			item.lastChild.onclick = null;
		},
		setText: function(item, text) {
			item.lastChild.innerHTML = text;
			item.callEvent("onTextChanged",[item._idd,text]);
		},
		setValue: function(item, val) {
			item._value = val;
		},
		getValue: function(item) {
			return item._value;
		}
	};
	dhtmlXForm.prototype.setFormData_myItem = function(name, value) {
		return this.doWithItem(name, "setValue", value);
	};
	dhtmlXForm.prototype.getFormData_myItem = function(name) {
		return this.doWithItem(name, "getValue");
	};
</script>
[/code]

Thanks for answers.

( The problem was the log shipping of my DB. )