Ola
Part 1
This is part 2 of our App Creation Process. We focus on the backend to store our data. The first backend we will look at is BANanoSQL, then BANanoSQLite & BANanoMySQL. The last two use inline PHP methodology.
In lesson 1 we created our UI, a form named 'form' with 4 textboxes named id,field1,field2,field3. Now we need to link these so that they get saved to the DB. Before we look at the DB infrastructure, lets ensure that the data source targets are linked on the form and we have some events linked to the form.
The link to the underlying data source for each form component is done via the 'name' property of an element. In lesson 1 we did not set any names for our elements but just specified the 'id' property and label.
Step 1: Update the name property of our input elements
For each of the elements, id, field1, field2, field3, update the Details.Name property to be exactly like the id. In the end you will have this code added to each of the elements after you update each element and save it in the property bag.
Without the name property specified, the .GetValues and .SetValues webix methods for form manipulation will not work.
Step 2: Update the buttons to have events attached to them.
In our form, we added buttons for some CRUD operations.
So what we have done here is to ensure that our form contents can be read and saved using the 'name' property of each input element. The second part was to ensure that each time the buttons are clicked, a callback event attached to each event is executed by BANano. This completes our preparations to use BANanoSQL.
Part 1
This is part 2 of our App Creation Process. We focus on the backend to store our data. The first backend we will look at is BANanoSQL, then BANanoSQLite & BANanoMySQL. The last two use inline PHP methodology.
In lesson 1 we created our UI, a form named 'form' with 4 textboxes named id,field1,field2,field3. Now we need to link these so that they get saved to the DB. Before we look at the DB infrastructure, lets ensure that the data source targets are linked on the form and we have some events linked to the form.
The link to the underlying data source for each form component is done via the 'name' property of an element. In lesson 1 we did not set any names for our elements but just specified the 'id' property and label.
Step 1: Update the name property of our input elements
For each of the elements, id, field1, field2, field3, update the Details.Name property to be exactly like the id. In the end you will have this code added to each of the elements after you update each element and save it in the property bag.
- ID
B4X:
id.SetName("id")
- Field 1
B4X:
field1.SetName("field1")
- Field 2
B4X:
field2.SetName("field2")
- Field 3
B4X:
field3.SetName("field3")
Without the name property specified, the .GetValues and .SetValues webix methods for form manipulation will not work.
Step 2: Update the buttons to have events attached to them.
In our form, we added buttons for some CRUD operations.
- New - when clicked its supposed to clear the form contents. The dependency for this is step 1
- Insert - when clicked, the form contents are saved to the database table i.e. INSERT INTO
- Update - when clicked the form contents are sved to the database table using the update method i.e. UPDATE ... WHERE
- Read - when clicked, use the 'id' content and read a record from the database table i.e. SELECT ... WHERE
- Delete - when clicked, use the 'id' content and delete the record from the database table i.e. DELETE ... WHERE
B4X:
btnnew.SetClick(BANano.CallBack(Me,"btnnew_click",Null))
B4X:
btninsert.SetClick(BANano.CallBack(Me,"btninsert_click",Null))
B4X:
btnupdate.SetClick(BANano.CallBack(Me,"btnupdate_click",Null))
B4X:
btnread.SetClick(BANano.CallBack(Me,"btnread_click",Null))
B4X:
btndelete.SetClick(BANano.CallBack(Me,"btndelete_click",Null))
So what we have done here is to ensure that our form contents can be read and saved using the 'name' property of each input element. The second part was to ensure that each time the buttons are clicked, a callback event attached to each event is executed by BANano. This completes our preparations to use BANanoSQL.
Attachments
Last edited: