L
L
Lumore2016-10-02 22:21:57
MySQL
Lumore, 2016-10-02 22:21:57

What is wrong with yii2 request?

There is a request like this:

$categoryArray = Category::find()->select(['id', 'parent_id AS parent', 'name AS text'])->all();

Then I translate to JSON:
$categoryArray = Category::find()->select(['id', 'parent_id AS parent', 'name AS text'])->all();

Should return [{id: id, parent: parent_id, text: name}], but only returns [{id: id}]
What's wrong with the query?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lumore, 2016-10-02
@Lumore

DAGpro : "To get an array, the asArray() method is missing before the all() method."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question