N
N
Nikita Kossman2020-07-07 00:55:38
PHP
Nikita Kossman, 2020-07-07 00:55:38

Checking for the same RedBeanPhp value?

I need help. How to check for same value in mysql table? For example, I have a $chat_id variable that always changes its value, and when the user enters a certain command, the chat id gets into the database, and I need the chat id value not to be recorded again. In other words, check for the same Chat-Id. I just started to do it, but for some reason it does not work, can you help me fix it?

$book = R::findOne('newchat', 'chat_id = ?', array([$chat_id]));
        if ( $book ) {
            //чат-ид существует
            if ($chat_id = $user->chat_id) {
                //если чат-ид совпадает, то нужно выдать сообщение
                $suc = 'Успешно';
            } else {
                $error = 'Ошибка';
            }
        }

newchat - table
chat_id - table field newchat I am using RedBeanPhp library, I will be very grateful if you can help
$chat_id = $result['message']['chat']['id'];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
necrodeflorator, 2020-07-07
@necrodeflorator

if ($chat_id = $user->chat_id) {
Is assignment necessary here? Maybe that's why it doesn't work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question