Complex where clause in Chrono Connectivity V5

How to use a complex WHERE clause with date comparison in ChronoForms Connectivity V5.

Overview

The issue occurs when migrating a custom date search condition from CF V4 to V5 due to incorrect array syntax and placeholder usage.
Build your WHERE condition as a string, then return it in an array using a colon prefix, ensuring proper PHP array structure and date function formatting.

Answered
ap apurvkolte 21 Aug, 2015
I have a custom search form. The search form has a date input. I want to show records with date greater than the date in search input

i had this in CC V4, where we just echoed the where clause, the code looked like below

echo " AND `dateofbirth` >= STR_TO_DATE('$dateofbirthFrom','%d-%m-%Y') ";


How can I translate this ti the CC V5 where clause ? As per the document, a complex where condition can be added using colon, so I tried,

$whereArray[":dateofbirth >= STR_TO_DATE('{$dateofbirthFrom}','%d-%m-%Y')"];
and
$whereArray[":dateofbirth_raw >= STR_TO_DATE('" . $dateofbirthFrom ."','%d-%m-%Y')"];

but its not working.

How do we use complex where clause in Chrono connectivity v5?
ap apurvkolte 21 Aug, 2015
Answer
I found the answer.

i collected all the echoed strings to a string and the use colon while returning the array.
Gr GreyHead 21 Aug, 2015
Hi apurvkolte,

I think that some PHP debugging is required here.

The syntax for a PHP array is => not >=

An array element uses () not []

This may be something closer to what you need
<?php
$dateofbirthFrom = ???;
return array( ":model.dateofbirth' = STR_TO_DATE('{$dateofbirthFrom}', '%d-%m-%Y') " );
?>

Bob

.

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