In Craft 2 you could creat a query with:
craft()->db->createCommand()->select() .... etc.
But in Craft 3 there is no select() Method in Craft::$app->db->createCommand().
Am I overlooking something?
In Craft 2 you could creat a query with:
craft()->db->createCommand()->select() .... etc.
But in Craft 3 there is no select() Method in Craft::$app->db->createCommand().
Am I overlooking something?
You can use either an activeRecord for it
$customer = Customer::find()
->where(['id' => 123])
->one();
Or a query
$rows = (new \craft\db\Query())
->select(['id', 'email'])
->from('user')
->where(['last_name' => 'Smith'])
->limit(10)
->all();
Variableyou can just return it. If you call it via controller request you can render itreturn $this->renderTemplate('path/to/template' ['data' => $rows])if it is an ajax request you need to encode it to json within your Controllerreturn $this->asJson(['data' => $rows]);It's hard to tell without further information – Robin Schambach Aug 27 '18 at 20:09