O
O
OxygenMan2020-05-30 16:49:46
PHP
OxygenMan, 2020-05-30 16:49:46

Why is RedBeanPHP not getting data from a table?

The thing is, I'm using RedBeanPHP. And I build queries like this:

$userID = $_GET['id'];  
    R::selectDatabase('database');
    $userDataID = R::findOne('post', 'user_id = ?', [$userID]);
    $postName = $userDataID->title;
    $postContent = $userDataID->content;
    $postTags = $userDataID->metaTags;

    echo "данные поста";

But echo only works with database queries where column names consist of letters in the same case. For example, $postName = $userDataID->title; - echo displays the $postName variable. But $postTags = $userDataID->metaTags; echo does not output the $postTags variable. I can't change columns in the database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OxygenMan, 2020-06-01
@OxygenMan

I solved the problem. finfoOne(); receives data from the table as an object. To represent this object as an array, use export $arrayUserDataID = $userDataID->export(); and from the variable $arrayUserDataID you can get data as from an array - $arrayUserDataID['title']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question