Forums

Chronoforms5 single record read on match

dzseti 24 Feb, 2014
Does anyone know how to read one matched record using Chronoforms5 using the DB Read function?

It's clear to me how to extract the whole table for the fields specifed into a data model, but not how to extract one record where - say - email=test@test.com
GreyHead 24 Feb, 2014
Answer
HI dzseti,

If you set Multi Read to No, or create a Where clause that only returns one record then you will only get one record. The WHERE clause is built in the Conditions box e.g.
<?php
return array( 'email' => 'test@test.com' );
?>

Bob
dzseti 24 Feb, 2014
Works fine - mnay thanks ...
chriso0258 25 Feb, 2014
Hello GreyHead,

If no match is found in the db, I would like to display a message such as, "No record was found". What would I need to add or do to accomplish this?

Thanks.
dzseti 25 Feb, 2014
I use this php in an Event Switcher module - the DB Read selects the (one) matching record as GreyHead showed us above - by searching the Joomla users table for a match on the e-mail address from the form. If a match is found then - together with other fields - 'id' is read from the users table (or DB). If this field is set, then a record has been found. If not, then there was no match:

<?php
if (isset($form->data['Data']['id'])) {
     return success;
}
else {
     return fail;
}
?>


If you want the form to be resubmitted when no record is found, then you could use the Event Loop module in the On Fail branch...
This topic is locked and no more replies can be posted.