connections.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 MongoDB as your default database.
  40. */
  41. Connections::add('default', array(
  42. 'type' => 'MongoDb',
  43. 'host' => 'localhost',
  44. 'database' => 'otakuhub',
  45. 'persistent' => 'foo'
  46. ));
  47. /**
  48. * Uncomment this configuration to use CouchDB as your default database.
  49. */
  50. // Connections::add('default', array(
  51. // 'type' => 'http',
  52. // 'adapter' => 'CouchDb',
  53. // 'host' => 'localhost',
  54. // 'database' => 'my_app'
  55. // ));
  56. /**
  57. * Uncomment this configuration to use MySQL as your default database.
  58. */
  59. // Connections::add('default', array(
  60. // 'type' => 'database',
  61. // 'adapter' => 'MySql',
  62. // 'host' => 'localhost',
  63. // 'login' => 'root',
  64. // 'password' => '',
  65. // 'database' => 'my_app'
  66. // ));
  67. ?>