read only specific data

azz13 07 Apr, 2014
It is posible use sql to read data by criteria like WHERE statement in version4
GreyHead 07 Apr, 2014
Hi azz13,

Please see this FAQ I think that the Conditions Box in the DB Read action uses the same syntax.

Bob
azz13 07 Apr, 2014
I use this sintax building WHERE statement

<?php
return array("model.field LIKE" => "%value%");
?>

If i write specific value all works great, but if I try read value from form this not work
GreyHead 17 Apr, 2014
Hi azz13,

Where and how are you getting a value from the form?

Bob
azz13 23 Apr, 2014
Hi
I try explain.
I have table with two columns "name" "groups".
For example record Mike group1,group4

Want to create form to filter group users. Create form with combobox with groups and submit button. Add "DB read" action to summit and add condition:
<?php return array('details.user_groups LIKE' => '%echo $form->data['search_group']%'); ?>

where user_groups is table field and search_group form field name. I see all results in table.

If i use

<?php return array('details.user_groups LIKE' => '%group3%'); ?>

all works great.

I use $form->data['search_group'] in custom code and all work great.

what am I doing wrong?
GreyHead 23 Apr, 2014
Answer
Hi azz13,

You've got some serious problems with your PHP. This may work better:
<?php
return array('details.user_groups LIKE' => "%{$form->data['search_group']}%");
?>

Bob
azz13 23 Apr, 2014
Hi Bob,

its now working just as I need .
Thank you for help!
This topic is locked and no more replies can be posted.