J
J
Just OK2020-04-20 17:40:32
PHP
Just OK, 2020-04-20 17:40:32

How to implement on ORM?

Hello.
I am using ORM RedBeanPHP.
I get data from tables thanks to two variables, these are $bd_table and $bd_table_param.
$bd_table - responsible for which table to get data from
$bd_table_param - responsible for the key in the table, i.e. same advert_id

$objects = R::findOne($bd_table, status > 0 AND type = ? AND $bd_table_param = ?", [$sendmail->type, $bd_table_param, $id]);


But this code does not work, because $bd_table_param is substituted into the SQL query already with quotes.

How can such a thing be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-20
@FanatPHP

You don't have to do that. The field name must be written directly into the condition

$objects = R::findOne($bd_table, "status > 0 AND type = ? AND id = ?", [$sendmail->type, $id]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question