Making another DB table and querying |
Post Reply |
Author | |
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
Posted: Aug 12 2016 at 10:00am |
To "apply" tables created with the engine, you should use a special Action that creates all non-existing tables. You can see its usage in the Pack 10 of Userspace01 for example. Once again, I don't recommend you to dive into this.
Why the source is rollbacked, I honestly don't know. Try to create by hand a PHP file with just the code to create a table and/or write some data, open it in browser after previewing a page in OE (example - you preview index.htm, in browser you see localhost:8087/index.htm, you change it to localhost:8087/mytest.php). When the code works as expected, add it into a Code Block Source type PHP position StartBody or into a Code Block Visual. |
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
Dmit, thank you for your reply.
P1. The problem I have is that the source is rollbacked even if I put the code manually when OE is executed. P2. I tried to create additional table by Ctrl+Shift+D, click the Tables button, but it isn't apply to oedb.db file acutally and just only original three tables exist in phpLiteAdmin. Could you explain "You can then apply your values to OE elements using JavaScript on page load" little more detailed? I appreciate your kind and prompt feedback. DJ
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
Hi.
Well, to do it with the dynamic engine, you select the page (not an element), Ctrl+Shift+D, click the Tables button on the top-right, and add new table with fields. But for your purposes it should be easier to write the code manually - using CREATE TABLE IF NOT EXISTS to create the table, get/write values etc. You can then apply your values to OE elements using JavaScript on page load or with Ajax, something like this in a Code Block (Source) type JavaScript: $(function(){ // .... var dbVal = "<?php echo $my_value; ?>"; $('#WE12345678 span').text(dbVal); // example for a Single-line text, found by its ID // .... }); |
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
Hi,
I am making the web project for device monitoring using openElement. I want to read the value from device and write it into DB (sqlite3), and querying it and displaying it to page. Using Dynamic OE, I have implemented the user DB but I don't know how to make another table into oedb and use it. Could you give your advice for it? Thank you! DJ |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |