本文整理汇总了PHP中app\models\Tag::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::tableName方法的具体用法?PHP Tag::tableName怎么用?PHP Tag::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::tableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTopics
public static function getTopics($tagId, $pages)
{
$key = 'topics-tag-' . $tagId . '-p-' . $pages->getPage();
$cache = Yii::$app->getCache();
$settings = Yii::$app->params['settings'];
if (intval($settings['cache_enabled']) === 0 || ($models = $cache->get($key)) === false) {
$models = static::find()->select(['id', 'topic_id'])->where(['tag_id' => $tagId])->orderBy(['id' => SORT_DESC])->offset($pages->offset)->with(['topic.node', 'topic.author', 'topic.lastReply'])->limit($pages->limit)->asArray()->all();
if (intval($settings['cache_enabled']) !== 0) {
$dep = new DbDependency(['sql' => 'SELECT MAX(updated_at) FROM ' . Tag::tableName() . 'where id = ' . $tagId]);
$cache->set($key, $models, intval($settings['cache_time']) * 60, $dep);
}
}
return $models;
}
示例2: up
public function up()
{
//初始化设置表
$tableName = Config::tableName();
$this->createTable($tableName, ['name' => Schema::TYPE_STRING . "(64) NOT NULL COMMENT '名称'", 'value' => Schema::TYPE_TEXT . " NOT NULL COMMENT '保存的值'", 'PRIMARY KEY (name)'], $this->tableOptions);
//附件表
$tableName = Storage::tableName();
$this->createTable($tableName, ['id' => Schema::TYPE_PK, 'uid' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '用户id'", 'name' => Schema::TYPE_STRING . " NOT NULL DEFAULT '' COMMENT '原始文件名'", 'path' => Schema::TYPE_STRING . " NOT NULL DEFAULT '' COMMENT '保存路径'", 'size' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '文件大小'", 'mime_type' => Schema::TYPE_STRING . "(50) NOT NULL DEFAULT '' COMMENT '文件类型'", 'bin' => Schema::TYPE_STRING . "(30) NOT NULL DEFAULT '' COMMENT '存储容器'", 'type' => Schema::TYPE_STRING . "(50) NOT NULL DEFAULT '' COMMENT '所属类型'", 'status' => Schema::TYPE_BOOLEAN . " NOT NULL DEFAULT '0' COMMENT '附件存储状态'", 'created_at' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间'", 'updated_at' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '修改时间'"], $this->tableOptions);
$this->createIndex('uid', $tableName, 'uid');
$this->createIndex('type', $tableName, ['type', 'id']);
//标签表
$tableName = Tag::tableName();
$this->createTable($tableName, ['id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . "(64) NOT NULL COMMENT '标签名'", 'icon' => Schema::TYPE_STRING . " NOT NULL DEFAULT '' COMMENT '标签图标'", 'description' => Schema::TYPE_TEXT . " NOT NULL COMMENT '版块介绍'", 'status' => Schema::TYPE_BOOLEAN . " NOT NULL DEFAULT '0' COMMENT '标签状态'", 'created_at' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间'", 'updated_at' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '修改时间'"]);
$this->createIndex('name', $tableName, 'name', true);
$this->createIndex('status', $tableName, ['status', 'id']);
//标签数据表
$tableName = TagItem::tableName();
$this->createTable($tableName, ['id' => Schema::TYPE_PK, 'tid' => Schema::TYPE_STRING . "(64) NOT NULL COMMENT '标签id'", 'target_id' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '目标id'", 'target_type' => Schema::TYPE_STRING . "(100) NOT NULL DEFAULT '' COMMENT '目标类型'", 'created_at' => Schema::TYPE_INTEGER . " UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间'"]);
$this->createIndex('item', $tableName, ['tid', 'target_id', 'target_type'], true);
$this->createIndex('target_type', $tableName, ['target_type', 'target_id']);
}
示例3: actions
public function actions()
{
return ['autocomplete' => ['class' => 'app\\components\\AutocompleteAction', 'tableName' => Tag::tableName(), 'field' => 'name']];
}