cakephp 3.0 使用表前缀? [英] cakephp 3.0 using tableprefix?

查看:16
本文介绍了cakephp 3.0 使用表前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续使用 cakephp 2 应用程序,我一直在尝试在我的模型中使用 $tablePrefix.这在 Cake 3 中仍然可用吗?或者我如何使用其他东西(请解释).

Moving on from a cakephp 2 application, I am stuck on trying to use $tablePrefix in my models. Is this still available in Cake 3? Or how can I use something else (please explain).

推荐答案

要像在 2.x 中那样获取每个表的前缀,只需在 Table 类中执行此操作:

To get prefix per table like you did in 2.x just do this in your Table class:

public function initialize(array $config) {
    $this->table('my_prefix_' . $this->table());
    ...
}

这篇关于cakephp 3.0 使用表前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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