-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientController.php
More file actions
executable file
·50 lines (41 loc) · 1.47 KB
/
Copy pathClientController.php
File metadata and controls
executable file
·50 lines (41 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace app\controllers;
use yii\rest\ActiveController;
use yii\db\Connection;
class ClientController extends ActiveController{
public $modelClass = 'app\models\Client';
public function behaviors()
{
return [
[
'class' => \yii\filters\ContentNegotiator::className(),
'only' => ['index', 'view'],
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
],
],
];
}
public function actions() {
$actions = parent::actions();
unset($actions['create']);
return $actions;
}
public function actionStudent(){
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$db_name = "siges_cnr";
$rows = (new \yii\db\Query())
->select(['persons.id','last_name','first_name'])
->from("$db_name.persons")
->all();
/*
$rows = (new \yii\db\Query())
->select(['persons.id', 'last_name','first_name','gender','birthday','active','rooms.room_name'])
->from('persons')
->join('INNER JOIN','room_has_person','room_has_person.students = persons.id')
->join('INNER JOIN','rooms','rooms.id = room_has_person.room')
->all();
*/
return $rows;
}
}