Buy Now
Sign in

CF6 Database connection failed

Chris1984NRW , September 21 2017
Answered
GreyHead
Hi Chris,

I learned a bit more about CFv6 over the weekend and - with some help from the Manual and some prompting from Max I got code like this to work on another site.
<?php
$old_array = $this->get('read_data25', array());
$new_array = array();
foreach ( $old_array as $v ) {
$new_array[$v] = $v;
}
$this->set('read_data25', $new_array);
?>

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
Chris1984NRW
I fill in a custom Code in the load event after the read_data25 Event
And what I fill in in the Options field? {var:read_data25}?
admin
Hi,

If your options are in the same table row and your "select type" is set to "first matching record" then the row fields need to be converted into a new array, the code posted by Bob should work but needs a small change:

<?php
$old_array = $this->get('read_data25.MODEL_NAME', array());
$new_array = array();
foreach ( $old_array as $v ) {
$new_array[$v] = $v;
}
$this->set('read_data25', $new_array);
?>

The custom code action should be after the "data read" and before the "display section".

Then you can use {var:read_data25} in the options fields.

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
But when I choose First Matchng record, then only One result would be displayed, right?

But when more then One Game is active, These Games must be displayed
C
Chris1984NRW
Hi Max,

I create the custom Code before the Display section:


The Detail of the custom Code:


I only get an Array as option


Here is the detailed view for read_data:


what is the error?
admin
Hi Chris,

Sorry, the code needs a change:

foreach ( $old_array as $k => $v ) {
$new_array[$k] = $v;
}

Then use {var:read_data25} in the options box!

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
Same result.
Do you Need an account to check this directly in my joomla?
admin
Hi Chris,

Please add a debugger before the "read data" and another after the "read data" and post the results.

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
Debugger before read_data:
Array
(
[option] => com_chronoforms6
[cont] => manager
[chronoform] => anmeldungfahrten
[__utma] => 13686116.284627528.1480674891.1502691711.1502693934.6
[__utmz] => 13686116.1502182504.2.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[phpbb3_kfo3u_k] =>
[phpbb3_kfo3u_u] => 459
[phpbb3_kfo3u_sid] => 2cbff43e31d9f8cd25db86507a6f014e
[1c7086c6490ea10cfedce69e211ed009] => 9d7246da8801d3d7aa2cab25e29e79f8
)


Debugger after read_data:
Array
(
[read_data19] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`auswaertsspiele`.`spiel`) AS `auswaertsspiele.count` FROM `bvbsups_auswaertsspiele_neu` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1';
[1] => SELECT `auswaertsspiele`.`spiel` AS `auswaertsspiele.spiel` FROM `bvbsups_auswaertsspiele_neu` AS `auswaertsspiele` WHERE `auswaertsspiele`.`aktiv` = '1' ORDER BY `auswaertsspiele.spiel` ASC LIMIT 100;
)

[var] => Array
(
[ewrewr] => ewrewr
)

)

[read_data25] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`auswaertsspiele_einstiegsorte`.`spiel`) AS `auswaertsspiele_einstiegsorte.count` FROM `bvbsups_auswaertsspiele_neu` AS `auswaertsspiele_einstiegsorte` WHERE `auswaertsspiele_einstiegsorte`.`aktiv` = '1';
[1] => SELECT `auswaertsspiele_einstiegsorte`.`einstiegsort1` AS `auswaertsspiele_einstiegsorte.einstiegsort1`, `auswaertsspiele_einstiegsorte`.`einstiegsort2` AS `auswaertsspiele_einstiegsorte.einstiegsort2`, `auswaertsspiele_einstiegsorte`.`einstiegsort3` AS `auswaertsspiele_einstiegsorte.einstiegsort3`, `auswaertsspiele_einstiegsorte`.`einstiegsort4` AS `auswaertsspiele_einstiegsorte.einstiegsort4` FROM `bvbsups_auswaertsspiele_neu` AS `auswaertsspiele_einstiegsorte` WHERE `auswaertsspiele_einstiegsorte`.`aktiv` = '1' LIMIT 100;
)

[var] => Array
(
[auswaertsspiele_einstiegsorte] => Array
(
[einstiegsort1] => ort1
ort2
ort3
ort4
[einstiegsort2] => ort2
[einstiegsort3] => ort3
[einstiegsort4] => ort4
)

)

)

)
admin
Hi Chris,

Sorry, I wanted to say one before the PHP action and another after it.

Also why do you have multiple values in the "einstiegsort1", your end goal is to have 4 options in the dropdown, one for each "einstiegsort", correct ?

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


admin
Hi Chris,

Good, now if you use {var:read_data25.auswaertsspiele_einstiegsorte} in the options box of the dropdown after the new code is used then you should get 4 options loaded, is this correct ?

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
Hi Max,

thanks, now its run.

But now when I choose a game in the first dropbox, in the second dropbox always shown the "einstiegsorte" from the first db entry.
It is possible when I choose a game the second dropdown with "einstiegsorte" load the correct "einstiegsorte"?
admin
Hi Chris,

But the 4 options are loaded in the 2nd dropdown or not ?

If they are then you can add some code to auto select the value you need, how do you choose the correct ort ?

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
Hi Max,

yes, the 4 Option are displayed.
But only from one game. When i choose a game the correct Option must be load.
Where can I place the Code and what Kind of Code?

Regards

Chris
admin

Hi Chris,

To be user we are on the same page, you want the correct value to be selected from the 4, correct ? or you want other values to be available too ?

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

Hi Max,

here is my db structure​
​​
​I have tweo drop boxes. In the first dropbox are the games​
​in the second "einstiegsorte"​
​when i choose a game. the secound dropbox must shown the correct einstiegsorte to the game
C
Chris1984NRW

db_data.JPG

Attachments
db_data.JPG
db_data.JPG
(17.44 KiB)
124 Downloads/Views
admin

Hi Chris,

Ok, in the "read data" Where conditions you must add the following:

spiel:{data:spiel_field_name}​
​aktiv:1

Are you doing that ?

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

Yes, now I get the error:

1054 Unknown column 'auswaertsspiele_einstiegsorte.aktiv' in 'where clause'  


​my where condition: ​
​spiel:{data:spiel}​
​aktiv:1