Forums

DB Read - Condition from actual Model

FenFire 10 Mar, 2016
Hello,

I have a problem with a DB Read action:
In a chrono form an entry from a database table is shown. The model I use is named Data. The ID of the user who made that entry is in the field "user_id".
Now I want to get the email for this user. It's saved in the users table.

For this I inserted a DB Read action (Model called Lender) with that condition:

<?php
return array("id" => Data[user_id]);
?>


Unfortunately, it doesn't get the right user email. Debugger tells me that no WHERE clause is used for the query. And I always get the same email from id 530 whereas tested entries had "user_id" 512 oder 528.

Is my syntax wrong? I don't get it. If I change it, e.g. to [Data][user_id] oder Data.user_id, then the query leads to an empty field.

Please help!!

Christian
GreyHead 10 Mar, 2016
Answer
Hi Christian,

Please try
<?php
return array("id" => $form->data['Data']['user_id'] );
?>
Please see this FAQ for more examples.
Bob
FenFire 10 Mar, 2016
Works perfect. Thanks a lot for an easy solution and an accurate answer.
This topic is locked and no more replies can be posted.