swi prolog mysql + web -


Sorry for my English, I want to create a simple website that will take data from the database and display it on the page. I have two problems:

1) Work with databases created in different modules:

 % database.pl: - module (database, [create_db_connect / 0 , Use_database / 0, query_to_database / 1, disconnect_database / 0]). : - use_module (library (ODBC)). Create_db_connect: - 'test', _, [user ('root'), password ('123') alias (myblog), open (one time)]). Use_database: - odbc_query (myblog, 'use test', _) Query_to_database (X): - odbc_query (myblog, 'Select data from testtable where id = 4', line (x)). Disconnect_database: - ODBCDiscunnect (miblog).  

Import this module into the main file:

 % el.pl: - use_module (library (http / thread_httpd)). : - use_module (library (http / http_dispatch)). : - use_module (library (http / html_write)). : - use_module (library (http / http_parameters)): - use_module (library (http / html_head)). : - use_module (database): - http_handler (root (.), Home, []). Server (port): - http_server (http_dispatch, [port (port)] home (_Request): - answer_html_page (title ('Sql'), [\ main_page]). Main_page - & gt; Create_db_connect, use_database, query_to_database (x), disconnect_database, html (div ('id = "tab_c2"', p ('~ w') - [x])).  

In this case, get the error:

  Warning: The forecasts are not defined if they are defined: Warning: runtime / Use 1, Use: - Dynamic Name / Arrival Warning: Warning: create_db_connect / 2, which is altered by the warning: /root/prologDev/el.pl:56:17: main_page / 2  < / Pre> 

but why? I got it in database.pl! Is defined in!

2) Although I do not like the decision, but I have modified the module database on it. Pl on:

 : - Module (database, [create_db_connect / 2, use_database / 2, query_to_database / 3, disconnect_database / 2]): - use_module (library (ODBC)). Create_db_connect (_, _): - odbc_connect ('test', _, [user '' ''], password ('123'), aka (myblog), open (one time)]). Use_database (_, _): - odbc_query (myblog, 'use test', _) Query_to_database (X, _, _): - odbc_query (myblog, 'Select data from testtable where id = 4', line ( X)). Disconnect_database (_, _): - ODBC_Discunnect (miblog)  

And now, the page is empty when I close Swift Contint Halt, there is an error: my_thread_global_end () Error: 1 does not exit thread.

Am I doing wrong?

Note that main_page // 0 is a non-terminal, Strong> no is a forecast. In order to call your database to predict from main_page // 0 , you have to type something like this:

  main_page -> {Create_db_connect, use_database, query_to_database (x), disconnected_database}, html (div ('id = "tab_c2"', p ('~ w') - [x])).  

{} / 1 build allows you to predict grammar rules (body) without it, without create_db_connect and others Other non-terminals ( create_db_connect // 0 , ...) will be interpreted as calls.

Usually non-terminal is expanded into two predictions by adding two arguments. So you have alerts:

  Warning: create_db_connect / 2, which is referred to by the warning: /root/prologDev/el.pl:56:17: 1 of the main_page / 2- / code > 

Comments