I am new to using the dhtmlx modules so I looked at the examples and got most of it working.
The only thing I can’t get to work is communication with mySQL database based on procedures.
I used the example of the form and the mySQL connection with the render_table and render_sql statements.
Is there anyone who can show me how to do the same with Procedures?
My procedures are to complex to insert them into the php statemants.
So instead of using render_table(“contacts”,“contact_id”,“fname,lname,email”) or render_sql(“SELECT * FROM contacts”,“contact_id”,“fname,lname,email”) I would like to use
something like render_sql(“retrieve_contacts()”,“contact_id”,“fname,lname,email”)
I have read that I should switch to mySQLi to use procedures, but I don’t know how to implement it into the example (as told I am new to this).
a) use Mysqli driver ( db_mysqli.php, MySQLi as second parameter of constructor )
b) in render_sql you can use ‘CALL retrieve_contacts()’ as first param mysqli_connector.zip (1.04 KB)
I checked the directories and the support for mySQLi on the Apche server and that was fine.
An XML file for tree data with mySQLi procedures is working fine, but the grid and form data is not working.
Fatal error: Uncaught exception ‘Exception’ with message ‘Source of data can’t be empty’ in C:\WebSites\Newtree\codebase\connector\db_common.php:192
Stack trace: #0 C:\WebSites\Newtree\codebase\connector\db_common.php(240): DataRequestConfig->set_source(’’) #1 C:\WebSites\Newtree\codebase\connector\base_connector.php(387): DataRequestConfig->parse_sql(‘call Ret_cont(’…’) #2 C:\WebSites\Newtree\xml\contacts.php(21): Connector->render_sql(‘call Ret_cont(’…’, ‘contact_id’, ‘fname,lname,ema…’) #3 {main}
thrown in C:\WebSites\Newtree\codebase\connector\db_common.php on line 192
The error is not clear to me. What ‘Source’ is empty?
I used the new db_common.php but that did not solve the problem. The error has changed to:
Fatal error: Uncaught exception ‘Exception’ with message ‘MySQL operation failed
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘call ret_cont()’ at line 1’ in C:\WebSites\Newtree\codebase\connector\db_mysqli.php:13
Stack trace: #0 C:\WebSites\Newtree\codebase\connector\db_common.php(631): MySQLiDBDataWrapper->query(‘SELECT call ret…’) #1 C:\WebSites\Newtree\codebase\connector\base_connector.php(434): DBDataWrapper->select(Object(DataRequestConfig)) #2 C:\WebSites\Newtree\codebase\connector\base_connector.php(388): Connector->render() #3 C:\WebSites\Newtree\xml\contacts.php(21): Connector->render_sql(‘call ret_cont()’, ‘contact_id’, ‘fname,lname,ema…’) #4 {main}
thrown in C:\WebSites\Newtree\codebase\connector\db_mysqli.php on line 13
As I notice it is trying to execute ‘SELECT call ret_cont()’ in stead of just the ‘call ret_cont()’ procedure.
The procedure itself is running in mySQL and is very simple:
CREATE PROCEDURE test.Ret_cont()
BEGIN
SELECT fname,lname,email
FROM contacts
ORDER BY lname;
END;