connections.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. /**
  9. * ### Configuring backend database connections
  10. *
  11. * Lithium supports a wide variety relational and non-relational databases, and is designed to allow
  12. * and encourage you to take advantage of multiple database technologies, choosing the most optimal
  13. * one for each task.
  14. *
  15. * As with other `Adaptable`-based configurations, each database configuration is defined by a name,
  16. * and an array of information detailing what database adapter to use, and how to connect to the
  17. * database server. Unlike when configuring other classes, `Connections` uses two keys to determine
  18. * which class to select. First is the `'type'` key, which specifies the type of backend to
  19. * connect to. For relational databases, the type is set to `'database'`. For HTTP-based backends,
  20. * like CouchDB, the type is `'http'`. Some backends have no type grouping, like MongoDB, which is
  21. * unique and connects via a custom PECL extension. In this case, the type is set to `'MongoDb'`,
  22. * and no `'adapter'` key is specified. In other cases, the `'adapter'` key identifies the unique
  23. * adapter of the given type, i.e. `'MySql'` for the `'database'` type, or `'CouchDb'` for the
  24. * `'http'` type. Note that while adapters are always specified in CamelCase form, types are
  25. * specified either in CamelCase form, or in underscored form, depending on whether an `'adapter'`
  26. * key is specified. See the examples below for more details.
  27. *
  28. * ### Multiple environments
  29. *
  30. * As with other `Adaptable` classes, `Connections` supports optionally specifying different
  31. * configurations per named connection, depending on the current environment. For information on
  32. * specifying environment-based configurations, see the `Environment` class.
  33. *
  34. * @see lithium\core\Adaptable
  35. * @see lithium\core\Environment
  36. */
  37. use lithium\data\Connections;
  38. /**
  39. * Uncomment this configuration to use MySQL as your default database.
  40. */
  41. Connections::add('default', array(
  42. 'type' => 'database',
  43. 'adapter' => 'MySql',
  44. 'host' => 'otaku.raylu.net',
  45. 'login' => 'otakuhub',
  46. 'password' => 'otakuhub',
  47. 'database' => 'otakuhub'
  48. ));
  49. /**
  50. * Uncomment this configuration to use MongoDB as your default database.
  51. */
  52. Connections::add('mongo', array(
  53. 'type' => 'MongoDb',
  54. 'host' => 'localhost',
  55. 'database' => 'otakuhub',
  56. 'persistent' => 'foo'
  57. ));
  58. /**
  59. * Uncomment this configuration to use CouchDB as your default database.
  60. */
  61. // Connections::add('default', array(
  62. // 'type' => 'http',
  63. // 'adapter' => 'CouchDb',
  64. // 'host' => 'localhost',
  65. // 'database' => 'my_app'
  66. // ));
  67. ?>