3

有什么方法可以将 Kohana 的 ORM 与 Amazon RDS 一起使用?

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

4

1 回答 1

4

是的,这是绝对可能的。我的网站有这个确切的配置。

在您的 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 模块是可选的,但非常好用。

希望这可以帮助!

于 2011-05-06T21:00:36.177 回答