本文整理汇总了PHP中app\models\User::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::tableName方法的具体用法?PHP User::tableName怎么用?PHP User::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::tableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
public function search($params, $whereParams = null)
{
$query = Note::find()->joinWith(User::tableName());
$isAdminPanel = $this->getScenario() === 'admin';
if ($whereParams) {
$query->where($whereParams);
}
if ($this->load($params) && $this->validate()) {
$query->andFilterWhere(['like', 'note.name', $this->name])->andFilterWhere(['like', 'user.name', $this['user.name']]);
if ($isAdminPanel) {
$query->andFilterWhere(['note.id' => $this->id])->andFilterWhere(['visibility' => $this->visibility]);
if (preg_match('/[\\d]{2}-[\\d]{2}-[\\d]{4}/', $this->created_at)) {
$query->andFilterWhere(['AND', ['>', 'note.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 00:00:00')->getTimestamp()], ['<', 'note.created_at', \DateTime::createFromFormat('d-m-Y H:i:s', $this->created_at . ' 23:59:59')->getTimestamp()]]);
}
} else {
$query->andFilterWhere(['like', 'description', $this->description]);
}
}
$noteSortAttributes = ['name' => ['asc' => ['note.name' => SORT_ASC], 'desc' => ['note.name' => SORT_DESC], 'label' => $this->getAttributeLabel('name')], 'created_at' => ['default' => SORT_DESC, 'label' => $this->getAttributeLabel('created_at')]];
if ($isAdminPanel) {
array_push($noteSortAttributes, 'id', 'user.name', 'visibility');
} else {
$noteSortAttributes['description'] = ['label' => $this->getAttributeLabel('description')];
}
$noteProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => $noteSortAttributes, 'defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => $isAdminPanel ? 10 : 9, 'defaultPageSize' => $isAdminPanel ? 10 : 9]]);
return $noteProvider;
}
示例2: behaviors
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'view', 'create', 'update', 'delete'], 'rules' => [['actions' => ['index', 'view', 'create', 'update', 'delete'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post'], 'send-message' => ['post']]], ['class' => 'yii\\filters\\HttpCache', 'only' => ['index'], 'lastModified' => function ($action, $params) {
$q = new Query();
$res = $q->from(User::tableName())->max('create_date');
return strtotime($res);
}]];
}
示例3: meAndMyFriends
/**
* Find by my ID and my friends.
*
* @param $id
* @return $this
*/
public function meAndMyFriends($id)
{
$modelClass = $this->modelClass;
$statusTableName = $modelClass::tableName();
$relationTableName = Relation::tableName();
$userTableName = User::tableName();
return $this->innerJoin(Relation::tableName(), $relationTableName . '.following_id = ' . $statusTableName . '.author_id OR ' . $relationTableName . '.follower_id = ' . $statusTableName . '.author_id')->innerJoin(User::tableName(), $relationTableName . '.following_id = ' . $userTableName . '.id OR ' . $relationTableName . '.follower_id = ' . $userTableName . '.id')->andWhere([User::tableName() . '.id' => $id])->orderBy($statusTableName . '.created_at DESC');
}
示例4: up
public function up()
{
$this->alterColumn(User::tableName(), 'role', 'smallint(6) NOT NULL DEFAULT 1');
$this->alterColumn(User::tableName(), 'status', 'smallint(6) NOT NULL DEFAULT 1');
$this->update(User::tableName(), ['status' => User::STATUS_ADMIN_ACTIVE], 'status = 10 and role = 1');
$this->update(User::tableName(), ['status' => User::STATUS_ACTIVE], 'status = 0 or (status = 10 and role > 1)');
$this->update(User::tableName(), ['role' => 3], 'role=1');
$this->update(User::tableName(), ['role' => User::ROLE_DEV], 'role=2');
$this->update(User::tableName(), ['role' => User::ROLE_ADMIN], 'role=3');
}
示例5: getQuery
/**
* @param array $params
* @param bool $filterByUser
* @return \yii\db\Query
*/
public static function getQuery($params = [], $filterByUser = true)
{
$portionCaloriesSql = self::getPortionCaloriesQuery('`d`.`id`')->createCommand()->sql;
$recipeCaloriesSql = self::getRecipeCaloriesQuery('`d`.`id`')->createCommand()->sql;
$productCaloriesSql = self::getProductCaloriesQuery('`d`.`id`')->createCommand()->sql;
$portWeightSql = self::getPortionsWeightQuery('`d`.`id`')->createCommand()->sql;
$recWeightSql = self::getRecipesWeightQuery('`d`.`id`')->createCommand()->sql;
$prodWeightSql = self::getProductsWeightQuery('`d`.`id`')->createCommand()->sql;
$query = Diary::find()->select(['`d`.*', '`u`.`weighing_day` AS `weighingDay`', "COALESCE(({$portionCaloriesSql}), 0) + COALESCE(({$recipeCaloriesSql}), 0) + COALESCE(({$productCaloriesSql}), 0) AS `calories`", "COALESCE(({$prodWeightSql}), 0) + COALESCE(({$recWeightSql}), 0) + COALESCE(({$portWeightSql}), 0) AS `weight`"])->from(self::tableName() . ' `d`')->leftJoin(User::tableName() . ' `u`', '`u`.`id` = `d`.`user_id`');
if ($filterByUser) {
$query->where(['`d`.`user_id`' => Yii::$app->user->id]);
}
return $query;
}
示例6: run
function run()
{
// && $model->contact(Yii::$app->params['adminEmail'])
$this->enable_form = $this->allow_comments();
$comment = new Comments();
$comment->parent_id = 0;
if ($this->enable_form && $comment->load(Yii::$app->request->post()) && $comment->validate()) {
Yii::$app->session->setFlash('commentFormSubmitted');
$comment->active = true;
$comment->user_id = Yii::$app->user->isGuest ? null : Yii::$app->user->identity->id;
$comment->ip = ip2long(Yii::$app->request->getUserIP());
$comment->agent = Yii::$app->request->getUserAgent();
$comment->saveUploadedImage('file');
$comment->save();
return Yii::$app->getResponse()->redirect(Yii::$app->getRequest()->getUrl());
}
$query = new Query();
$query->addSelect('c.*, f.filename, f.thumb_filename, f.size, u.username')->from([Comments::tableName() . ' c'])->leftJoin(User::tableName() . ' u', 'u.id = c.user_id')->leftJoin(Files::tableName() . ' f', 'f.id = c.image_id')->where(['c.active' => true])->andWhere(['c.post_id' => $this->post_id]);
$comment->post_id = $this->post_id;
return $this->render('comments/comments_box', ['comments' => $this->buildTree($query->all()), 'model' => $comment, 'enable' => $this->enable_form]);
}
示例7: actionIndex
/**
* Все
*
* @param null $q
* @param null $id
* @return array
*/
public function actionIndex($q = null, $id = null)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$out = ['results' => ['id' => '', 'text' => '']];
if (!is_null($q)) {
$query = new Query();
$query->select('id, name, surname')->from(User::tableName())->where(['like', 'name', $q])->orWhere(['like', 'surname', $q])->limit(20);
$command = $query->createCommand();
$data = $command->queryAll();
$users = [];
foreach ($data as &$user) {
$users[] = ['id' => $user['id'], 'text' => $user['name'] . ' ' . $user['surname']];
}
$out['results'] = $users;
} else {
if ($id > 0) {
$user = User::findIdentity($id);
if ($user) {
$out['results'] = ['id' => $user->id, 'text' => $user->name . ' ' . $user->surname];
}
}
}
return $out;
}
示例8: actionIndex
public function actionIndex()
{
$dataProvider = new ActiveDataProvider(['query' => User::findBySql('select * from ' . User::tableName() . ' where isadmin = 0'), 'pagination' => ['pagesize' => '20']]);
return $this->render('index', array('dataProvider' => $dataProvider));
}
示例9: down
public function down()
{
$this->dropTable('group');
$this->dropColumn(\app\models\User::tableName(), 'avatar');
return true;
}
示例10: down
public function down()
{
$this->dropColumn(User::tableName(), 'options');
}
示例11: down
public function down()
{
$this->dropTable(User::tableName());
}
示例12: testTableName
public function testTableName()
{
$this->assertEquals('user', User::tableName());
}
示例13: getReceiver
/**
* @return \yii\db\ActiveQuery
*/
public function getReceiver()
{
return $this->hasOne(User::className(), ['id' => 'receiver_id'])->from(User::tableName() . ' receiver');
}
示例14: down
public function down()
{
echo "m150926_151034_init_user reverted.\n";
$this->delete(User::tableName(), ['id' => [1, 2]]);
return true;
}
示例15: getCalendarEvents
/**
* @return \yii\db\ActiveQuery
*/
public function getCalendarEvents()
{
return $this->hasMany(CalendarEvent::className(), ['calendar_id' => 'calendar_id'])->viaTable(User::tableName(), ['id' => 'user_id']);
}