PDO Wrapper

Hello,

i have some trouble to load my form with data in my DB ( DB2 )

Here is my code

load.php

[code]<?php

/*
 * Tableau des options de configuration de la base DB2
*/
$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 'macaronDB/classes/pdo_connect.php';


$ipa = '*LOCAL' ;
$usr = 'XXXXX' ;
$pwd = 'XXXXX' ;
$cnx_db01 = new pdo_connect($ipa, $usr, $pwd, $options ) ;

$sql = "select * from M400F.ART fetch first 1 rows only";

$stat = pdo_connect::getStatement($cnx_db01, $sql);

$result = pdo_connect::getFetchAssoc($stat);

//create connector for dhtmlxForm using connection to mySQL server
$form = new FormConnector($cnx_db01);
//table name, id field name, fields to use to fill the form
$form->render_table("M400F.ART","ARTNUM","ARTNUM, ARTDEP, ARTLIB");[/code]

I have an internal server error. The connection works but i don’t know how to load the form with a specifical wrapper :question:

add the next line before render_table command

$form->enable_log("db.log");

and check the content of db.log file - it must contain some details about the error.

Here is the only error which is present several times in the db.log file.

[code]

Log started, 01/07/2014 01:07:35

Undefined index: ids at /www/zendsvr/htdocs/developpement/stage/dhtmlxConnector/codebase/form_connector.php line 56

!!!Uncaught Exception
Code: 0
Message: ID parameter is missed[/code]

Message: ID parameter is missed

Server side script expects that data for the form will be requested like next

some.php?id=123

where 123 - id of form record. If you are calling script without id parameters - it is not clear which record must be loaded and server side code throws the above error.

So, if i understood, in my form.html, i must have :

myForm = new dhtmlXForm("form_container", formData); myForm.load("load.php?id=????"); myForm.attachEvent("onButtonClick", function(name){ window[name](); });

And replace ??? with an ID. But i don’t know where i am suppose to find this ID and i don’t understand the utility of it…

Sorry for these “stupid” questions Stanislav and thanks for your help :slight_smile:

You have the id of record in DB ( ARTNUM ), right ?
And when you want to show data in the form - you want to show the data of some specific record, right ? So you probably have this id on client side ( as selected row in grid, or in some js var )

Thank you Stanislav,the mysql connection works :exclamation: :slight_smile:
But now i want to change the connection and for example i want to use db_oracle.php. What do I must change in load.php to have a different connection ? Because i always have a mysql error in the log…

You need to include the related connector file ( “connector/db_oracle.php” ) and use DB type as second pararemeter

$form = new FormConnector($cnx_db01, "Oracle");

docs.dhtmlx.com/connector__php__ … ample.html

Thank you Stanislav :slight_smile: