如何在cakephp表上创建按钮以创建新表? [英] How to create a button on a cakephp table to create a new table?

查看:93
本文介绍了如何在cakephp表上创建按钮以创建新表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿!我需要主客户端数据库表上的新建位置按钮来创建新的数据库表。我该怎么做?

Hey! I need the New Location button on the main client database table to create a new database table. How do I do that?

这些表将成为每个位置的客户列表。每个客户都有一个位置ID,可以将其放置在正确的表中。这样,我们将获得一个客户端列表表,其中包含来自所有位置的所有客户端(图1),以及每个位置的单独表。

These tables would be the client list for each location. Each client would have a location id that would place them in the correct table. This way we would have a Client List Table with all clients from all locations (image 1) and a separate table for each location.

Cakephp版本-4.0.7

Cakephp version - 4.0.7

推荐答案

如果我正确理解,您希望将一个客户链接到一个商店位置(或者可能是多个位置)。

If I understand correctly you want to linked one client to one shop location (or maybe many location).

第一种方法是一对多。 (客户端属于位置,而位置属于hashas许多客户端)您需要与客户端创建表,并放入新列,如 location_id 。然后只需为客户端设置多个位置之一(在编辑中或将postButton与location_id和client_id配合使用)。

First way is one to Many. (client belongs to location and location hasMany clients) You need to create table with you clients and put new column like location_id. Then simply set one of many location to client (in edit or use postButton with location_id and client_id).

第二种方法是多对多的。这意味着许多客户端属于许多位置,许多位置属于许多客户端。喜欢文章中的标签。您需要创建三个表。一个与客户,一个与位置,一个与客户连接在一起。

Secondly way is many to many. That means many clients belongs to many locations and many locations belongs to many clients. Like tags in articles. You need to create three tables. One with clients, One with locations and One to connect it together.

通过这种方式,客户表和位置表没有任何其他列可直接指向自己(例如location_id或client_id)。您需要制作第三个名称为 clients_locations 的表,并添加带有客户表和位置表 ID的行。简单示例:

In this way Clients Table and Location Table dont't have any additional columns to direct to themselfs (like location_id or client_id). You need to make third table with name clients_locations and add colmuns with ID of Client Table and Location Table. Simple example:

   +--------+-------------+-----------+
   | id.    | location_id | client_id |
   +--------+-------------+-----------+
   |   1    |       3     |    10     |
   +--------+-------------+-----------+
   |   2    |       4     |     3     |
   +--------+-------------+-----------+
   |   3    |       7     |     9     |
   +--------+-------------+-----------+
   |   4    |       4     |    40     |
   +--------+-------------+-----------+

在Cakephp中,其名称为属于Tony。

In Cakephp its name as BelongsToMany.

这篇关于如何在cakephp表上创建按钮以创建新表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆