如何将 Amazon RDS 与 Kohana 的 ORM 结合使用

发布于 2024-11-02 16:42:38 字数 145 浏览 4 评论 0原文

有没有办法将 Kohana 的 ORM 与 Amazon RDS 结合使用?

我找到了 Amazon PHP SDK,但我不确定如何将其插入 Kohana 以便 ORM 使用它。我也找不到任何适用于 Amazon RDS 的 Kohana 模块。有什么建议吗?

Is there any way to use Kohana's ORM with Amazon RDS?

I found the Amazon PHP SDK but I'm not sure how to plug it into Kohana so that the ORM uses it. I also couldn't find any Kohana module for Amazon RDS. Any suggestion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心房的律动 2024-11-09 16:42:38

是的,这是绝对可能的。我的网站有这样的配置。

在您的 AWS 管理控制台中,您需要获取 RDS 服务器的“端点”。该名称很长,以您的数据库实例的名称开头。 (例如,请参阅下面的代码)

接下来,打开数据库配置文件:application/config/database.php

在“默认”配置中,将主机名更改为端点。还将数据库、用户名和密码更改为您设置的任何内容:

'default' => array
    (
            'type'       => 'mysql',
            'connection' => array(
                    /**
                     * The following options are available for MySQL:
                     *
                     * string   hostname     server hostname, or socket
                     * string   database     database name
                     * string   username     database username
                     * string   password     database password
                     * boolean  persistent   use persistent connections?
                     *
                     * Ports and sockets may be appended to the hostname.
                     */
                    'hostname'   => 'your-db-instance.njgo7sn43.us-east-1.rds.amazonaws.com',
                    'database'   => 'db_name',
                    'username'   => 'username',
                    'password'   => 'SuperCaliFrajilisticExpiAliDocious',
                    'persistent' => FALSE,
            ),
            'table_prefix' => '',
            'charset'      => 'utf8',
            'caching'      => FALSE,
            'profiling'    => TRUE,
    ),

另外,在您的 application/bootstrap.php 文件中,确保取消注释数据库模块:

Kohana::modules(array(
    'database'   => MODPATH.'database',   // Database access
    'orm'        => MODPATH.'orm',        // Object Relationship Mapping
));

ORM 模块是可选的,但非常好用。

希望这有帮助!

Yes, this is absolutely possible. I have this exact configuration for my website.

In your AWS management console, you will need to get the "endpoint" of your RDS server. The name is quite long and begins with the name of your DB instance. (See the code below for example)

Next, open your database configuration file: application/config/database.php

In the 'default' configuration, change your hostname to the endpoint. Also change the database, username and password to whatever yours is set up with:

'default' => array
    (
            'type'       => 'mysql',
            'connection' => array(
                    /**
                     * The following options are available for MySQL:
                     *
                     * string   hostname     server hostname, or socket
                     * string   database     database name
                     * string   username     database username
                     * string   password     database password
                     * boolean  persistent   use persistent connections?
                     *
                     * Ports and sockets may be appended to the hostname.
                     */
                    'hostname'   => 'your-db-instance.njgo7sn43.us-east-1.rds.amazonaws.com',
                    'database'   => 'db_name',
                    'username'   => 'username',
                    'password'   => 'SuperCaliFrajilisticExpiAliDocious',
                    'persistent' => FALSE,
            ),
            'table_prefix' => '',
            'charset'      => 'utf8',
            'caching'      => FALSE,
            'profiling'    => TRUE,
    ),

Also, in your application/bootstrap.php file, make sure to UN-comment the database module:

Kohana::modules(array(
    'database'   => MODPATH.'database',   // Database access
    'orm'        => MODPATH.'orm',        // Object Relationship Mapping
));

The ORM module is optional but very nice to use.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文