Buy Now
Sign in

CF6 Database connection failed

Chris1984NRW , September 21 2017
Answered
C
Chris1984NRW
Hello,

i have problems with the component chronoforms v6 and joomla 3.

I would like to create a formular which read data from an database.

When i create an new form, I use read data.
but when i configure read data I cant choose a table, because the database connection failed:


When I create a new model, then I can choose a db table:


But when I apply the changes, get back to the designer and then get already back to the read data setup, the db connection failed again:


Does anyone knows an solution?

kind regards

Chris
admin
Hi Chris,

This has already been fixed as per the patch sent by the email, correct ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
C
Chris1984NRW
Hi Max,

thats right.

But I have Problems to get data results ^^

I would like to get the data from the Field spiel where aktiv=1 is.

How I have to config the read data to get this results?

I Need the results in a dropdown field
admin
Hi Chris,

In the where conditions:
aktive:1

If you need one record only then set the "Select type" to "First matching", if you want the results in a dropdown then use the "Key/val pairs" option instead.

Then use {var:read_data_name} in the dropdown options box

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
C
Chris1984NRW
Hi Max,

it works with the database table.
In the where conditions i add this.
now i get the error:
1054 Unknown column 'Model.spiel, aktiv' in 'field list'

What is wrong?
Can u help me again?
C
Chris1984NRW
I solved the problem.
I insert an debugger:
Array
(
[read_data19] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`auswaertsspiele`.`spiel`) AS `auswaertsspiele.count` FROM `bvbsups_auswaertsspiele` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1';
[1] => SELECT `auswaertsspiele`.`spiel` AS `auswaertsspiele.spiel` FROM `bvbsups_auswaertsspiele` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1' ORDER BY `auswaertsspiele.spiel` ASC LIMIT 100;
)

[var] => Array
(
[0] => Array
(
[auswaertsspiele] => Array
(
[spiel] => Bayer Leverkusen - Borussia Dortmund (02.12.2017) | Fahrpreis: 16,- €
)

)

)

)

)

The result is correct. but how I get the result from the array into a dropbox?
I insert in the options {var: read_data19} but the dropbox is empty
C
Chris1984NRW
I had an Space by var: and read_data.
That was wrong.
Now in the dropbox shown "Array" but Not the result. What is the reason Max?
admin
Hi Chris,

For the dropdown to be populated by the read data, the "read data" select type should be set to key/value pairs

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
C
Chris1984NRW
Thanks, now I get the Array.
But in the dropbox was already shown one Array.
But I had 2 Arrays in my SQL database.
Debugger:
Array
(
[read_data19] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`auswaertsspiele`.`spiel`) AS `auswaertsspiele.count` FROM `bvbsups_auswaertsspiele` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1';
[1] => SELECT `auswaertsspiele`.`aktiv` AS `auswaertsspiele.aktiv`, `auswaertsspiele`.`spiel` AS `auswaertsspiele.spiel` FROM `bvbsups_auswaertsspiele` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1' ORDER BY `auswaertsspiele.spiel` ASC LIMIT 100;
)

[var] => Array
(
[1] => TESTTEST!!!
)

)

[read_data25] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`auswaertsspiele_einstiegsorte`.`einstiegsort`) AS `auswaertsspiele_einstiegsorte.count` FROM `bvbsups_auswaertsspiele_einstiegsorte` AS `auswaertsspiele_einstiegsorte` WHERE `auswaertsspiele_einstiegsorte`.`aktiv` = '1';
[1] => SELECT `auswaertsspiele_einstiegsorte`.`aktiv` AS `auswaertsspiele_einstiegsorte.aktiv`, `auswaertsspiele_einstiegsorte`.`einstiegsort` AS `auswaertsspiele_einstiegsorte.einstiegsort` FROM `bvbsups_auswaertsspiele_einstiegsorte` AS `auswaertsspiele_einstiegsorte` WHERE `auswaertsspiele_einstiegsorte`.`aktiv` = '1' ORDER BY `auswaertsspiele_einstiegsorte.einstiegsort` ASC LIMIT 100;
)

[var] => Array
(
[1] => Lüdenscheid Mitte (ehemals AVIS Center)
)

)

)


SQL Result in phpmyadmin:

SELECT `auswaertsspiele`.`aktiv` AS `auswaertsspiele.aktiv` , `auswaertsspiele`.`spiel` AS `auswaertsspiele.spiel`
FROM `bvbsups_auswaertsspiele` AS `auswaertsspiele`
WHERE `auswaertsspiele`.`aktiv` = '1'
ORDER BY `auswaertsspiele.spiel` ASC
LIMIT 100

auswaertsspiele.aktiv auswaertsspiele.spiel
1 Bayer Leverkusen - Borussia Dortmund (02.12.2017) ...
1 TESTTEST!!!
C
Chris1984NRW
No idea?
C
Chris1984NRW
I Change my db structure:


My read data;


My Dropdown:


In the dropdown, all four "einsteigsorte" should be displayed.
The form only displays "einstiegsorte1"


What did I wrong?
Any idea?
C
Chris1984NRW
No reply?
Its so difficult with chronoforms?
F
Funk001
Hi Chris,

I have been a system administrator for 15 years and I have the same problem but I do not understand it either
and the documetation suks

kind regards,
Rob Funk
GreyHead
Hi Chris,

The note in the Select type box says that to "Return an array of key/value pairs, two fields must be provided" I understand this to mean that it will return a key and a value from each selected row of the table.

BUT your table is not set up in this way, you have all the values you want returned in the same table row. So you need to set Select Type to "First matching record" that will read the data you want - but it will not be in the correct format to use in the dropdown - you can fix that easily enough using a Custom Code action to convert the single data array returned which is like array('value1', 'value2', . . .) into the required format of array( array('value1', 'value1'), array(value2', value2), . . . )

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
Chris1984NRW
Hi Bob,

Thanks for your response.

Can you tell me an example code?
I dont know i can do this
C
Chris1984NRW
Bob?
C
Chris1984NRW
I am now very frustrated that I can not get help.

Without a solution CF6 is useless for me!
C
Chris1984NRW
When you tell me a way to fix it, i would like to Change the db structure.
GreyHead
Hi Chris,

Sorry that Max hasn't replied to you - I know little about CFv6 so far and have been away over the holidays.

The code you need would be something like this
<?php
$old_array = $this->data['some_name'];
$new_array = array();
foreach ( $old_array as $v ) {
$new_array[$v] = $v;
}
$this_data['some_name'] = $new_array;
?>


Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
Chris1984NRW
<?php
$old_array = $this->data['read_data25'];
$new_array = array();
foreach ( $old_array as $v ) {
$new_array[$v] = $v;
}
$this_data['read_data25'] = $new_array;
?>

So?