Forums

Converting a CF4 to CF5 - DB Read issues

rcadmin 20 Jul, 2014
Converting a CF4 to CF5.

CF4 uses the "DB Record Loader" action with settings as follows:
[attachment=0]CC-old.PNG[/attachment]

CF5 uses "DB Read"
[attachment=0]CC-old.PNG[/attachment]

The problem is I don't know what I need to put in the CF5 settings to achieve the same as those of CF4. I can't quiet work out what goes where ie. where do I put the references to uniqueid?
GreyHead 23 Jul, 2014
Hi rcadmin,

CFv4 had two ways of setting a 'WHERE' clause, the basic DB Field = Request Parameter or the WHERE box.

In CFV5 these are both in the Conditions box. Please see this FAQ for the syntax to use.

Bob
rcadmin 23 Jul, 2014
Thanks for that just need a little more clarificaiton. I have a field called "uniqueid" and I will be passing a parameter called "uniqueid".

ie. I will need
<?php
return array('model_id.uniqueid' => 'value');
?>


But I am not sure how to get the 'value' part from the parameter; even after looking at the examples.
GreyHead 24 Jul, 2014
Hi rcadmin,

In ChronoForms:
$form->data['uniqueid']
but if that is a string it needs to be quoted!

Bob
rcadmin 25 Jul, 2014
Ok so to confirm, if I visit the following

http://www.mysite.com/index.php?option=com_chronoforms5&chronoform=emailstaff&uniqueid=aqwe231

then I can us the following in the DB read action for CF5

<?php
$value = $form->data['uniqueid']
return array('model_id.uniqueid' => $value);
?>
GreyHead 25 Jul, 2014
Hi rcadmin,

Yes that looks OK to me, subject to the need to quote the string. I'd try it and see if it works.

Bob
rcadmin 27 Jul, 2014
It's not working but I appear to have a few issues so I will step back a step.

Here is on onload sequence
[attachment=0]On Load.PNG[/attachment]

The form always loads i.e. something is always found meaning that

<?php
$value = $form->data['uniqueid']
return array('model_id.uniqueid' => '$value');
?>


always returns a result which is not possible.
GreyHead 28 Jul, 2014
Hi rcadmin,

There's a ; missing from the end of the first line of code. Is that the problem?

Bob
rcadmin 28 Jul, 2014
Hi Bob,

Fixed that but it made no difference. The DB Read always returns the first entry in the table.
GreyHead 29 Jul, 2014
Hi rcadmin,

Then the problem may be the quotes round '$value' I don't think that will work the way you want it to. If the value is an integer you can leave them off. See the FAQ for a different method it it is a string.

Bob
rcadmin 29 Jul, 2014
Hi

So I changed the code to
<?php
$var = $form->data['uniqueid']
$var = JRequest::getVar('param','', 'get');
$dbo = \GCore\Models\MODEL_ID::getInstance()->dbo;
$var = $dbo->quote($var);
return array (":model_id.uniqueid > {$var}");
?>


But I get the same result. At the moment what is most confusing is that the first record is always returned which means the redirection never happens there is always a positive hit.
rcadmin 29 Jul, 2014
aaagh .. left a
;
out. let me try again.
rcadmin 29 Jul, 2014
Made no difference.
GreyHead 02 Aug, 2014
Hi rcadmin,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.

Bob
rcadmin 03 Aug, 2014
Hi Bob

This won't help as they error happens before submitting i.e the onload part is meant to be redirecting so that page does not load without the uniqueid parameter. It however loads regardless.

But here is the debug info anyway

Array
(
[10] => Array
(
[Check Honeypot] => Array
(
[0] => Honeypot check passed.
)

)

[5] => Array
(
[Email] => Array
(
[0] => An email with the details below could NOT be sent:
[1] => To:
[2] => Subject:
[3] => From name:
[4] => From email:reception@school.nz
[5] => CC:
[6] => BCC:
[7] => Reply name:Andre
[8] => Reply email:noreply@school.nz
[9] => Attachments:
[10] => Body:
<table>
<tr><td><strong>CONTACT DETAILS</strong></td><td> </td></tr>
<tr><td>First Name</td><td>Andre</td></tr>
<tr><td>Surname</td><td>Basel</td></tr>
<tr><td>Email</td><td>noreply@school.nz</td></tr>
<tr><td>Phone</td><td>1234566</td></tr>
<tr><td><strong>MESSAGE</strong></td><td> </td></tr>
<tr><td>Subject</td><td></td></tr>
<tr><td>Message</td><td>Test</td></tr>
</table><br /><br />IP: 124.150.174.28
)

)

)

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