public static function userGroups($user_id) { $dsn = Yii::$app->db->dsn; if (strtolower(substr($dsn, 0, 5)) == "mysql") { $members = Yii::$app->db->createCommand("SELECT GROUP_CONCAT(group_id) as id FROM " . GrpUsr::tableName() . "\n\t\t\t\tWHERE user_id = :id AND isdel = 0")->bindValues([":id" => $user_id])->queryScalar(); } else { $members = Yii::$app->db->createCommand("SELECT array_agg(group_id) as id FROM " . GrpUsr::tableName() . "\n\t\t\t\t\tWHERE user_id = :id AND isdel = 0")->bindValues([":id" => $user_id])->queryScalar(); } $groups = json_decode(str_replace(["{", "}"], ["[", "]"], $members)); return $groups == null ? [] : $groups; }
public function getMemberId() { $members = $this->db->createCommand("SELECT array_agg(user_id) as id FROM " . GrpUsr::tableName() . "\n\t\t\t\tWHERE group_id = :id AND isdel = 0")->bindValues([":id" => $this->id])->queryScalar(); return json_decode(str_replace(["{", "}"], ["[", "]"], $members)); }