octobercms mysql_OctoberCMS插件形成数据库关系(OctoberCMS plugin form database relationships)...

OctoberCMS插件形成数据库关系(OctoberCMS plugin form database relationships)

我在10月份的CMS生成器上制作插件。 在后端创建了几个数据库表格,模型和表单。 现在尝试添加表单元素(复选框),并希望从其他表中获取复选框值。

例:

Table 1: categories

Model: Categories (relates to table categories)

Columns: id(INT, AI), name(VARCHAR), types(TEXT)

Table 2: types

Model: Types (relates to table types)

Columns: id(INT, AI), type(INT)

所以在类别创建表单中我想分配类型。 例如:

Category name: News

Types: 1, 3, 7 (from table: types column: type)

我如何做这项工作?

I am making a plugin on October CMS builder. Created couple db tables, models and forms in backend. Now trying to add form element (checkboxes) and want to make checkbox values to be taken from other table.

Example:

Table 1: categories

Model: Categories (relates to table categories)

Columns: id(INT, AI), name(VARCHAR), types(TEXT)

Table 2: types

Model: Types (relates to table types)

Columns: id(INT, AI), type(INT)

So in category creation form i want to assign types. For example:

Category name: News

Types: 1, 3, 7 (from table: types column: type)

How do i make this work?

原文:https://stackoverflow.com/questions/41512294

更新时间:2019-12-19 18:56

最满意答案

好吧,我找到了。 在Rainlab插件中关闭和选择Lookep。

在我的类别模型中,我添加了一个函数来从其他表中获取所需的数据,它工作。

public function getTypesOptions()

{

}

Ok i found it. Lookep up in Rainlab plugin for relations and options.

In my Category model i have added a function to fetch required data from other table and it worked.

public function getTypesOptions()

{

}

2017-01-06

相关问答

最大的问题是你的查询变得更加复杂。 假设您想要查找所有者余额超过10,000美元的所有帐户。 在规范化的数据库中,这将是这样的: select firstname, lastname, accountnumber, balance

from account

join customeraccount using (accountnumber)

join customer using (customernumber)

where balance>10000

但有三个accountnumber字段,它

...

对于OctoberCMS来说,它似乎是一个空数据库的开始。 也许你可以从一个空的数据库开始,然后导入wordpress shenanigans作为替代解决方案。 It looks like it is manditory for OctoberCMS to start with an empty database. Maybe you can start from an empty database and import the wordpress shenanigans later as an

...

为什么不使用initSettingsData函数,你可以像这样使用它: class Settings extends Model

{

public $implement = ['System.Behaviors.SettingsModel'];

// A unique code

public $settingsCode = 'my-settings';

// Reference to field configuration

public $setting

...

好吧,我找到了。 在Rainlab插件中关闭和选择Lookep。 在我的类别模型中,我添加了一个函数来从其他表中获取所需的数据,它工作。 public function getTypesOptions()

{

}

Ok i found it. Lookep up in Rainlab plugin for relations and options. In my Category model i have added a function to fetch required data from

...

我想出了一个创建自定义插件的解决方案,该插件扩展了10月CMS后端翻译服务。 我已将下面的代码添加到我的插件的boot()方法中: // Custom Backend Translator that handles the Backend localisation with the Rainlab Translator plugin

$this->app->singleton('translator', function ($app) {

$loader = $app['

...

试想你会怎么说。 在您的情况下,它听起来像一个客户有很多帐户,一个帐户属于一个客户。 因此,您可以将hasMany()放在Customer模型中,将belongsTo()放在Account模型中。 class Customer extends Model {

public function accounts() {

return $this->hasMany('App\Account');

}

}

class Account extends Model {

...

好。 我找到了两种方法可以实现这一点,下面是这些。 方式一 Product.php (plugins \ technobrave \ products \ models) <?php namespace Technobrave\Products\Models;

use Model;

use technobrave\productcategory\Models\ProductCategory as ProductCategory;

public function getCategoryOptio

...

为此,您必须使用模型类手动处理保存过程。 1-打开您的模型类。 2-写一个模型甚至函数就像public function afterSave(){} 例如,如果我在reservation模型中有一个total字段,我想要将此字段值自动插入另一个名为accounting表中。 public function afterSave(){

$accounting = \Namespace\Pluginname\Models\Accounting::find(1);

$accounting-

...

好,朋友们, 最后,我使用了https://github.com/saribe/eModal库,看起来它基于我的上述场景,因为这个库提供了一个用ajax请求打开模态的功能。 谢谢。 Ok guys, Eventually, I have used https://github.com/saribe/eModal library and it seems like it is working based on my above scenario as this library is providin

...

您描述的场景是在属性图模型中通过提到的超边界模式@Pangea处理的。 您基本上将边缘(需要边缘进出)转换为顶点。 使用图形,我会将其视为非规范化,而不是更多不同的建模抽象。 对于边缘上的边缘的原生支持,没有任何标记您的问题的图表直接支持这样的功能。 正如您所做的那样包括Titan和OrientDB,我假设您正在评估TinkerPop作为解决方案的一部分,我可以进一步说,由于Blueprints不支持边缘上的边缘,所以Blueprints图也不会。 就遍历而言,我不能说我完全遵循“递归遍历”的意思

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值