Forums

DB Read problem

jpurlings 06 Nov, 2016
Hey,

I use a DB Read in the on load event to populate fields of my form. But they stay blank. The query that the DB Read generates is:

SQL=SELECT `DATA5`.`PARTNERS` AS `DATA5.JJPARTNERS`, `DATA5`.`RESOURCES` AS `DATA5.RESOURCES`, `DATA5`.`ACTIVITIES` AS `DATA5.ACTIVITIES`, `DATA5`.`PROPOSITION` AS `DATA5.PROPOSITION`, `DATA5`.`RELATIONSHIP` AS `DATA5.RELATIONSHIP`, `DATA5`.`CHANNELS` AS `DATA5.CHANNELS`, `DATA5`.`SEGMENTS` AS `DATA5.SEGMENTS`, `DATA5`.`COSTS` AS `DATA5.COSTS`, `DATA5`.`REVENUES` AS `DATA5.REVENUES` FROM `#__CHRONOENGINE_CHRONOFORMS_BUSINESSMODEL` AS `DATA5` WHERE `DATA5`.`USER_ID` = '42'

I have two questions about this query that maybe are the cause of the field staying blank:
[list]The table name in the query is #__CHRONOENGINE_CHRONOFORMS_BUSINESSMODEL, but in phpmyadmin it is cd2jq_chronoengine_chronoforms_businessmodel. Does this cause the fields to stay empty?[/list]
[list]The column names the query generates are DATA5.PARTNERS, ... but the field name is Partners, does this cause the fields to stay blank?[/list]

I don't know where to look else anymore, hopefully you can help me.

Greetings.
GreyHead 07 Nov, 2016
Hi jpurlings,

a. No, the #__ prefix is replaced by the database prefix that is set up for your site in the Global Configuration.

b. Probably - I think that MySQL column names are case sensitive.

Bob
jpurlings 07 Nov, 2016
Bob,

Thanks for your answer.

Chronoforms converts the column names I type in the textbox to uppercases. I tested this by writing a wrong column name, then Chronoforms generates an error frontend in which the sql-statement can be seen. By debugging, I get the impression that the array indeed is empty. What to do about it?

Greetings.
GreyHead 07 Nov, 2016
Hi jpurlings,

ChronoForms doesn't do any case conversion on data from your form that I know of. Perhaps something else on your site is doing that - is there any CSS being applied to those form elements that would change the case?

Bob
jpurlings 07 Nov, 2016
Hi,

No, I don't apply any css in the form. But I think this isn't the problem, because the sql-statement doesn't generate an error when using the correct column names. They correspond to the field names. I don't get it. All that is needed is placing a Read DB in the on load, before render HTML, fill in the names and the condition, and then the fields should be populated, am I right?

I can't share the site with you, because I am building it offline...

What I can I do to help you find the answer with me?
jpurlings 07 Nov, 2016
By the way, this is the screenprint with the debugger on. Looks blank...

Greetings.
GreyHead 07 Nov, 2016
Hi jpurlings,

Is the screenshot from a Debugger in the On Load event? If so there is no evidence of a DB Read there. You should see the query and the results.

Bob
jpurlings 07 Nov, 2016
Ow, sorry,

I thought the debug should be placed on top in on load. I placed it lower in on load, and it shows that the array is filled the right way:
Array
(
    [Data5] => Array
        (
            [0] => Array
                (
                    [Partners] => Test7
                    [Resources] => Test9
                    [Activities] => Test8
                    [Proposition] => Test1
                    [Relationship] => Test2
                    [Channels] => Test3
                    [Segments] => Test4
                    [Costs] => Test5
                    [Revenues] => Test6
                )
        )
)


The field names are the same as the names in the array between brackets (but then without the brackets of course). But frontend, the textboxes stay emtpy. How come?

Thank you.
GreyHead 08 Nov, 2016
Hi jspurlings,

Please try setting Multi read and Enable Model ID to No in the DB Read settings, that should make sure that the names match up.

ChronoForms does (almost) everything in strict sequence - so a Debugger at the top of the ON Load only shows the data available at that step in the event processing.

Bob
jpurlings 08 Nov, 2016
Hi Bob,

Thank you.

I tried this before, did it again now, but it doesn't help. Array values are:

Array
(
    [0] => Array
        (
            [Partners] => Test7
            [Resources] => Test9
            [Activities] => Test8
            [Proposition] => Test1
            [Relationship] => Test2
            [Channels] => Test3
            [Segments] => Test4
            [Costs] => Test5
            [Revenues] => Test6
        )
)


These are correct. Since the column names are generated by the form fields, the columns names are also correct. I don't get it, it should work as far as I am concerned, probably I am missing something. Hopefully you can help me to find it...

Greetings.
GreyHead 08 Nov, 2016
Hi jpurlings,

The array there doesn't appear to have a name so maybe you need to add a Model ID? If you post the whole of the Debugger output including the MySQL query that might help more.

Bob
jpurlings 08 Nov, 2016
Hi Bob,

The query is:

Array
(
[5] => Array
(
[DB Read] => Array
(
[Queries] => Array
(
[0] => SELECT `BMData`.`Partners` AS `BMData.Partners`, `BMData`.`Resources` AS `BMData.Resources`, `BMData`.`Activities` AS `BMData.Activities`, `BMData`.`Proposition` AS `BMData.Proposition`, `BMData`.`Relationship` AS `BMData.Relationship`, `BMData`.`Channels` AS `BMData.Channels`, `BMData`.`Segments` AS `BMData.Segments`, `BMData`.`Costs` AS `BMData.Costs`, `BMData`.`Revenues` AS `BMData.Revenues` FROM `cd2jq_chronoengine_chronoforms_businessmodel` AS `BMData` WHERE `BMData`.`user_id` = '42'
)

)

)

)
jpurlings 17 Nov, 2016
Bob,

I still can't get it working. Can you help me?
GreyHead 17 Nov, 2016
Hi jpurlings,

Please post the whole of the Debugger output.

Bob
jpurlings 17 Nov, 2016
Okay,

Thank you!

I attached it!
GreyHead 17 Nov, 2016
Answer
Hi jpurlings,

Thank you - now I'm more confused as that data array still has no name :-(

By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
jpurlings 17 Nov, 2016
Okay Bob,

The site wasn't online yet. I placed it online. Will send you credentials with a PM.

Thanks for your help.
jpurlings 17 Nov, 2016
Bob,

To add. What I want to achieve is that the form under the menu Business Model Canvas can be filled and saved by a logged in user. After having saved, when the user comes back at the form, it should be filled with the data entered earlier.

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

VPS & Email Hosting 20% discount

{item:title} {images:#}