Skip to content

Commit

Permalink
为了方便用户更改表名,避免表名直接定死
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuiyong committed Oct 15, 2016
1 parent 0cc43c9 commit fc65609
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions controllers/ConfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public function beforeAction($action) {
*/
public function actionIndex() {

// 为了方便用户更改表名,避免表名直接定死
$groupTable = Group::tableName();
$projectTable = Project::tableName();
// 显示该用户为管理员的所有项目
$project = Project::find()
->leftJoin(Group::tableName(), '`group`.`project_id`=`project`.`id`')
->where(['`group`.`user_id`' => $this->uid, '`group`.`type`' => Group::TYPE_ADMIN]);
->leftJoin(Group::tableName(), "`$groupTable`.`project_id`=`$projectTable`.`id`")
->where(["`$groupTable`.`user_id`" => $this->uid, "`$groupTable`.`type`" => Group::TYPE_ADMIN]);

$kw = \Yii::$app->request->post('kw');
if ($kw) {
Expand Down
7 changes: 5 additions & 2 deletions controllers/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ public function actionIndex($page = 1, $size = 10) {
*/
public function actionSubmit($projectId = null) {

// 为了方便用户更改表名,避免表名直接定死
$projectTable = Project::tableName();
$groupTable = Group::tableName();
if (!$projectId) {
// 显示所有项目列表
$projects = Project::find()
->leftJoin(Group::tableName(), '`group`.`project_id`=`project`.`id`')
->where(['project.status' => Project::STATUS_VALID, '`group`.`user_id`' => $this->uid])
->leftJoin(Group::tableName(), "`$groupTable`.`project_id` = `$projectTable`.`id`")
->where(["`$projectTable`.status" => Project::STATUS_VALID, "`$groupTable`.`user_id`" => $this->uid])
->asArray()->all();
return $this->render('select-project', [
'projects' => $projects,
Expand Down

0 comments on commit fc65609

Please sign in to comment.