Seriously Newbie - DB Read

U Can Drive 06 Dec, 2015
I am seriously struggling with the DB Read, could you please show me how to fill in the DB Read form specifically the "Conditions" box for this simple form.

I have done some very basic level programming way back when (Basic & Cobol) but PHP is totally new to me and I'm banging my head daring not to ask basic questions...

What I am trying to achieve (so you can advice if I'm following the wrong track altogether):
I own a driving school, I am wanting users to register on the website using their License number.
Once registered I want an admin user (an instructor) to be able to access their records using the students License number.
In their records I then want to keep records of up to 80 driving lessons:
Date, Time, Length, Odometer Start, Odometer End, basic scoring for certain manoeuvres, Homework, Comments.

I then want parents to be able to gain the students permission by registering and using their child's License number and get a report of single lessons. (At the moment I am likely to tell parents to access their child's account, maybe much easier.)

I may need to set it up (looking at the Create Table form there is a limit to the fields) with a different form for each lesson, recorded based on their License number and Lesson Number License 1234567 Lesson 05 = 1234567-05
GreyHead 06 Dec, 2015
Hi U Can Drive,

For the Conditions box settings please see this FAQ

You may need to chat to someone with some Joomla! / database design experience before you get much further as a pencil sketch now will save you a lot of time later.

It sounds as though you are going to need separate tables for students, lessons, parents (to link to the student id). For instructors you probably just need to have a separate user group.

+ The student table would contain a unique_id, possibly the licence number, plus the name and other profile stuff and any other data that occurs only once per student.

+ The lesson table would contain the student id, date, time, . . .

+ The parent table would include the student id and any other data you need beyond the Joomla! user data.

There is no significant limit on the number of column in a table - it is a maximum of 4,096 columns and/or 65,535 bytes.

You may well find ChronoConnectivity helpful to manager listings e.g. showing all the lesson records for a student.

Note: Please take care of data protection issues if you give parents permission to access their children's accounts - it will depend on the ages, consent and local laws.

U Can Drive 08 Dec, 2015
Thank you for that, but I don't think you really appreciate my serious level of newbieness at this. While I am good at manipulating programs to do my bidding (Joomla! Excel) I only have little and old experience at actual programming.

While the FAQ looks helpful to someone with insight it makes no sense to me at all as I have no reference point to understand what I am reading.

To get me started could you please show me a simple script from the above images to reload a form with the answers previously entered?

I really do appreciate your time and am sorry to be such a nuisance but I assure you, once I am able to see this working I will purchase a license possibly even with the PayPal extra as I intend to add a payment option in the future as well.
GreyHead 08 Dec, 2015
Hi U Can Drive,

I suggest that you start with a very simple form - maybe just one input and a submit button. Add a DB Save action to the On Submit event and Create a table to save the data. Once you have that we can see how to re-load saved data. this video may help with this part.

U Can Drive 12 Dec, 2015
Thanks Bob,

I have done that already, the above image shows the fields Name & Address.

Both set up as VARCHAR 64 & 255

I now need to use the DBRead function to reload the form but have no idea what to put in the "Conditions" box.
I've added "Name,Address" to both the "Fields" and "Order" boxes and selected the table they are in.

What do I need to put in the "Conditions" box to access the users pre-saved information.

Do I need this, and how do I edit it for my form (if at all)?
$user = \JFactory::getUser();
return array('model_id.user_id' => $user->id);

And what do I need for each field? The FAQ you linked above is not helpful as I don't know what the different statements ('model_id.column' / 'value' / $form->data) are all relating to so I can change them to be relevant to my form.
GreyHead 12 Dec, 2015
Hi U Can Drive,

The $form->data array is the data array that ChronoForms uses to handle all of the form data.

A model ID is a way to define a sub-array of the $form->data array when you want to keep some of the data distinct.

In your test case you can disable the Model ID in the DB Read action; and leave the model_id. part out of the Conditions statement.

U Can Drive 12 Dec, 2015
Got it!

No matter what I tried I could not make it work.

I have not been using a logged in user to fill in the form, as such no user ID has actually been recorded!
GreyHead 12 Dec, 2015
Hi U Can Drive,

You can use the Authenticator action to limit access to Logged in Users when you get to that stage.

This topic is locked and no more replies can be posted.