BullGuard Antivirus Sale - 60% Off with openElement !
Forum openElement Homepage
Forum Home Forum Home >

openElement

> Dynamic OE - Databases, etc
  New Posts New Posts RSS Feed - Making another DB table and querying
  FAQ FAQ  Forum Search   Register Register  Login Login

Making another DB table and querying

 Post Reply Post Reply
Author
Message
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 Août 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Topic: Making another DB table and querying
    Posted: 10 Août 2016 at 15:49
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
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group
Avatar

Joined: 31 Mai 2012
Status: Offline
Points: 5266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: 10 Août 2016 at 23:23
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
// ....
});
Back to Top
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 Août 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Posted: 11 Août 2016 at 22:47
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
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group
Avatar

Joined: 31 Mai 2012
Status: Offline
Points: 5266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: 12 Août 2016 at 11:00
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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.11
Copyright ©2001-2012 Web Wiz Ltd.

This page was generated in 0,032 seconds.