本文整理汇总了PHP中app\models\Users::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::tableName方法的具体用法?PHP Users::tableName怎么用?PHP Users::tableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::tableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLevelUpInfoByUserIdOrder
public static function getLevelUpInfoByUserIdOrder($userId, $levelOrder)
{
$sql = "SELECT u.score,u.lesson,u.credit,u.create_time,l.credit as level_credit,l.score as level_score,l.name,l.login_duration,l.content FROM " . self::tableName() . " ul LEFT JOIN " . Users::tableName() . " u ON ul.user_id = u.id LEFT JOIN " . Level::tableName() . " l ON ul.level_id = l.id WHERE ul.user_id=:user_id AND l.order=:level_order";
$result = Yii::$app->db->createCommand($sql, [':user_id' => $userId, ':level_order' => $levelOrder])->queryOne();
return $result;
}
示例2: getAllInfoById
public function getAllInfoById($activityId)
{
$result = Yii::$app->db->createCommand('SELECT u.username,u.score,uf.birthday,u.level_id,uf.photo FROM ' . self::tableName() . ' au LEFT JOIN ' . UsersInfo::tableName() . ' uf ON au.user_id = uf.id LEFT JOIN ' . Users::tableName() . ' u ON au.user_id = u.id WHERE au.activity_id=:activity_id', [':activity_id' => $activityId])->queryAll();
return $result;
}
示例3: actionIndex
public function actionIndex()
{
$keyword = Yii::$app->request->get('keyword', '');
$levelId = Yii::$app->request->get('level_id', '');
$district = Yii::$app->request->get('district', '');
$sex = Yii::$app->request->get('sex', '');
if (empty($keyword) && empty($levelId) && empty($district) && empty($sex)) {
throw new ServerErrorHttpException('шп╖ш╛УхЕехЕ│щФохнЧя╝Б');
}
$levelList = Level::getAll();
$districtList = Train::$districtList;
$userName = '';
$certificateNumber = '';
$credentialsNumber = '';
if (preg_match("/^[- ]+\$/", $keyword)) {
$userName = $keyword;
} else {
if (strlen($keyword) > 10) {
$credentialsNumber = $keyword;
} else {
$certificateNumber = $keyword;
}
}
$order = Yii::$app->request->get('order');
$query = Users::find()->from(Users::tableName() . ' u')->select("u.*,ui.account_location,ui.sex")->leftJoin(UsersLevel::tableName() . ' ul', ' u.id = ul.user_id')->leftJoin(UsersInfo::tableName() . ' ui', ' u.id = ui.user_id');
if (!empty($order)) {
$query->orderBy($order);
}
$query->andFilterWhere(['!=', 'u.level_id', '1']);
if (!empty($levelId)) {
$query->andFilterWhere(['u.level_id' => $levelId]);
}
if (!empty($district)) {
$query->andFilterWhere(['account_location' => $district]);
}
if (!empty($sex)) {
$query->andFilterWhere(['sex' => $sex]);
}
if (!empty($userName)) {
$query->andFilterWhere(['like', 'name', $userName]);
}
if (!empty($certificateNumber)) {
$query->andFilterWhere(['like', 'certificate_number', $certificateNumber]);
}
if (!empty($credentialsNumber)) {
$query->andFilterWhere(['like', 'credentials_number', $credentialsNumber]);
}
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 15]);
$models = $query->offset($pages->offset)->limit($pages->limit)->all();
$result = [];
if (!empty($models)) {
foreach ($models as $key => $val) {
$result[$key]['name'] = $val['username'];
$result[$key]['photo'] = UsersInfo::getPhotoByUserId($val['id']);
$result[$key]['birthday'] = UsersInfo::getBirthdayByUserId($val['id']);
$result[$key]['level_id'] = $val['level_id'];
$result[$key]['user_id'] = $val['id'];
}
}
$data = ['models' => $result, 'pages' => $pages, 'count' => $query->count(), 'levelList' => $levelList, 'districtList' => $districtList, 'keyword' => empty($keyword) ? '' : $keyword, 'levelId' => empty($levelId) ? '' : $levelId, 'district' => empty($district) ? '' : $district, 'sex' => empty($sex) ? '' : $sex];
return $this->render('index', ['data' => $data]);
}