Chronoform v6 read data where conditions syntax

GKCE3U 13 Jan, 2018
Hi guys,
congratulations for the excellent work you are doing.
I'm having some difficulties using chronoforms v6. I explain:
I have created 1 new joomla user additional field (province) in the joomla login form with related groups and access levels. There are one sql dropdowns that take the value from the tb_province tables in the database. The value of the new joomla user additional field is stored by joomla on xxx_fields_values database table. I managed to load the value into text field field_text_province of chronoforms using one read data (read_data_province). With a second read data (read_data_id_province) recovery the id value of the province value in tb_province of the additional field.

Now I need to retrieve data and populate a dropdown where the id_province in tb_city table (linked to the tb_province) equal to id of tb_province to the recovered one with the read_data_id_province. What syntax should I use in Where Contitions?

Thank you guys!
Max_admin 15 Jan, 2018
Answer
Hi GKCE3U,

The syntax is like this:
table_file_name:value

The "value" can be anything, you usually use {data:form_field_name} to get a form field value or url parameter value, or use {var:action_name} to get a value from a result returned by some action.

I'm not sure how your form/tables are setup exactly so can not tell you the exact syntax!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
peppelaria 03 Apr, 2018
Hi Max.
How can I get results where condition is null?
if I give this condition:User.deleted:NULL it gives "where User.deleted = 'NULL'"

'NULL' is parsed like string than I get wrong results.

Thanks in advance for your reply
Max_admin 04 Apr, 2018
Hi peppelaria,

Please use this format for null:
field_name/is:null
Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
peppelaria 04 Apr, 2018
Hi Max. Your solution doesn't work.
this is the answer I get: "1064 You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near ''null'' at line 1".

Any suggestion?
healyhatman 04 Apr, 2018
Try field_name/default_value

EDIT: This was a useless suggestion, my bad
peppelaria 04 Apr, 2018
thanks for your reply.
now the error is: "1064 You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near 'DEFAULT_VALUE ''' at line 1"
healyhatman 04 Apr, 2018
"where User.deleted = NULL" ? get rid of the quotes around it?
peppelaria 04 Apr, 2018
the problem are the quotes around NULL.
it is passed to the query as a string using the syntax User.deleted:NULL.
In the debugger i have => where User.deleted = 'NULL'
healyhatman 04 Apr, 2018
User.deleted/is:null
or
User.deleted:is:null
or
User.deleted:/is:null ?

Just guess at this point🙂
peppelaria 04 Apr, 2018
Hi healyhatman.
Thanks for yous suggestions.
Unfortunatelly in new chronoforms shortcode syntax everithing after colon is put in the query as a string.

for example User.deleted:is:null returns WHERE User.deleted = 'is:null'
healyhatman 04 Apr, 2018
oh oh!!! how about custom PHP code block, called "getanull", and all it has is "return null;"

Then User.deleted:{var:getanull}

Just as a hack til Max comes back
peppelaria 04 Apr, 2018
thank you.
I will try as soon as possible and let you know if it works
peppelaria 04 Apr, 2018
Hi healyhatman.

Same result.
Everything after colon is treated as a string, than User.deleted:{var:getnull} returns WHERE User.deleted = ''
peppelaria 04 Apr, 2018
what I need to have my form work correctly is something that returns WHERE User.deleted IS NULL.

Is there a way to give conditions using php code like in cf5?

example: <?php return array('User.deleted' => 'IS NULL'); ?>
healyhatman 04 Apr, 2018
value:/is:null

Just tested it and it's working for me - searching a table it gave me all the rows where "value" was empty.
peppelaria 04 Apr, 2018
I just tested it but it returns
WHERE `User`.`deleted` = ''
healyhatman 04 Apr, 2018
Can you post a screenshot of your read data action?
healyhatman 04 Apr, 2018
And just to make sure, that table has a column called "deleted" ? And there are rows in there where the deleted value is empty?
peppelaria 04 Apr, 2018
yes sir. It has a column called deleted having values equals to NULL
healyhatman 04 Apr, 2018
Don't know what to tell you sorry, it's working perfectly for me.
Chronoform v6 read data where conditions syntax image 2
peppelaria 04 Apr, 2018
it works for you because te value in your table is empty. In my table the value is a datetime and it is set to null
healyhatman 04 Apr, 2018
Right well I can't help you then we've reached the end of my knowledge. I suppose you could use a php block with

$myArray = $this->get("read_data12.Customer", "");
return array_filter($myArray, function($k) {
return is_null($k["deleted"]); } );

Replacing read_data12 with whatever your black label is
peppelaria 05 Apr, 2018
Hi healyhatman.
I appreciate your help.
I will try to find a way to figure it out a most afficient solution
healyhatman 02 May, 2018
Did you figure it out? If not I'm pretty sure Max sent me an email when I asked him about it
peppelaria 03 May, 2018
Hi healyhatman. The solution is: Model.field/IS:{var:Null}

Best regards
gix.vax 03 May, 2018
you have a ":" before "/"

????

":" should go only before "null"
peppelaria 03 May, 2018
Hi gix.
Using the above code

Model.field/IS:{var:Null}

it returns exactly wath I want: all fields where field is NULL.
Using different syntax it returns "null" as a string than the query gives wrong result.
gix.vax 03 May, 2018
hi peppelaria
yes, sorry, i was referring to a couple of posts before

healyhatman
(http://www.chronoengine.com/forums/posts/t104925/p376756#p376756 )
have ":" before "/" and i can't understand why.
peppelaria 17 Aug, 2018
Hi Max. Is there a Short code to ti give to a read data a "in" condition?

Something like: "id/in:{data:someId}"

Thank you for your help
healyhatman 17 Aug, 2018
you need it in an array. So use a PHP action to get all the IDs on their own in an array and /in will work with the var.

For null use {value:null}
peppelaria 17 Aug, 2018
hy healyhatman, for null i managed simply using "field/is".

it gives "field IS NULL" in the query that is simply what i needed.

Thank you very mutch for your help, I will try to transform the string in array
peppelaria 17 Aug, 2018
Hi healyhatman, it works like a charm.

Thankyou very mutch
healyhatman 19 Aug, 2018
peppelaria instead of having to use php to get an array try the following in the where conditions of your second read data action
model.field/in:{var:read_data#.[n].model.field}
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger