V
V
Vladislav Olegovich2019-04-30 19:31:05
PHP
Vladislav Olegovich, 2019-04-30 19:31:05

RedBeanPHP not pulling data from bean?

I'm trying to get the id from the bean, but for some reason it does not pull out the id and writes null, despite the fact that the bean successfully pulls from the base and there is a ['id'] key there.

$user = R::dispense('users');
        $user->name = $data['login'];
        $user->email = $data['email'];
        $user->password = password_hash($data['password'], PASSWORD_DEFAULT); 
        R::store($user);
        $user_id = R::find('users', 'WHERE name = ?', array($data['login']));
        $_SESSION['user_id']=$user_id->id; 
        или
        $_SESSION['user_id']=$user_id['id'];//оба варианта не работают, хотя везде манулы смотрю- везде обе записи правы

all the same, when I dump, it displays 'user_id' with an empty value (at the same time, the bean is successfully unloaded).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Olegovich, 2019-04-30
@FreshMeatInIT

I wrote a crutch - the main thing is that it works)

$current_user = R::findOne('users', 'WHERE name = ?', array($data['login']));
        $_SESSION['user']=$current_user;
        $_SESSION['user_id'] = $current_user->id;
        unset($_SESSION['user']);
        b_dump($_SESSION);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question