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!

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:
http://bvb-supporters-lennetal.de/images/customcode_overview.JPG

The Detail of the custom Code:
http://bvb-supporters-lennetal.de/images/customcode_detail.JPG

I only get an Array as option
http://bvb-supporters-lennetal.de/images/customcode_result.JPG

Here is the detailed view for read_data:
http://bvb-supporters-lennetal.de/images/customcode_read_data_.JPG

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!

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!

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!