connections.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, 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' => 'my_app'
  45. // ));
  46. /**
  47. * Uncomment this configuration to use CouchDB as your default database.
  48. */
  49. // Connections::add('default', array(
  50. // 'type' => 'http',
  51. // 'adapter' => 'CouchDb',
  52. // 'host' => 'localhost',
  53. // 'database' => 'my_app'
  54. // ));
  55. /**
  56. * Uncomment this configuration to use MySQL as your default database.
  57. */
  58. Connections::add('default', array(
  59. 'type' => 'database',
  60. 'adapter' => 'MySql',
  61. 'host' => '192.168.100.102',
  62. 'login' => 'benchmarkdbuser',
  63. 'password' => 'benchmarkdbpass',
  64. 'database' => 'hello_world',
  65. 'encoding' => 'UTF-8'
  66. ));
  67. ?>