How to get data from category_translation db table

Is there a global way to get any data from the db table, as I could not find anything that did work(new to Yii2, and working on a already build yii2 application).

Working in a controller with the following code:

$results = Yii::app()->db->createCommand('SELECT * FROM category_translation')->queryAll();

return $results;

This will not return a thing but only an error.


This is a Yii 1.1 syntax.

Are you really sure that you are working on a Yii 2.0 application?

In yii2 your code gonna look like:

$results = Yii::$app->db->createCommand('SELECT * FROM category_translation')->queryAll();

but if u ask me - make direct queries without AR to gather data is kinda lame.

Also there’s another thing that may occur: db component not called “db”.

Anyway next time make sure u know the field where u gonna work before accept project :)

Sometimes you have to learn on the job :wink:

Anyway, problem solved.