{PL} - 3.4.1 Konfiguracja bazy danych

Cake PHP używa konfiguracji bazy danych zapisanej w pliku app/config/database.php. Przykładowy plik konfiguracyjny można znaleźć w app/config/database.php.default. Końcowa konfiguracja powinna wyglądać mniej więcej tak:

var $default = array('driver'      => 'mysql',
                     'persistent'  => false,
                     'host'        => 'localhost',
                     'login'       => 'cakephpuser',
                     'password'    => 'c4k3roxx!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');
  1. var $default = array('driver' => 'mysql',
  2. 'persistent' => false,
  3. 'host' => 'localhost',
  4. 'login' => 'cakephpuser',
  5. 'password' => 'c4k3roxx!',
  6. 'database' => 'my_cakephp_project',
  7. 'prefix' => '');

Tablica $default jest używana dopóki inne połączenie nie jest zdefiniowane we właściwości $useDbConfig w modelu. Dla przykładu jeśli nasza aplikacja wykorzystuje dodatkową bazę danych nie użytą w tablicy $default. Możemy użyć jej w naszym modelu przez stworzenie nowego połączenia z bazą danych $legacy na podobnej zasadzie co nasza tablica $default przez ustawienie var $useDbConfig = 'legacy' w wykorzystywanym modelu.

Wypełnij pary klucz/wartość w tablicy konfiguracyjnej w takiej postaci jakiej potrzebujesz

Klucz Wartość
driver Nazwa sterownika bazy danych dla którego ta tablica konfiguracyjna jest stworzona. Przykład: mysql, postgres, sqlite, pear-drivername, adodb-drivername, mssql, oracle, lub odbc.
persistent Używa czy nie, stałego połączenia z bazą dancych
host Host serwera bazy danych (lub adres IP).
login Nazwa użytkownika dla konta
password Hasło użytkownika do konta
database Nazwa bazy danych
prefix (opcjonalnie) ciąg znaków który poprzedza wszystkie nazwy tabel w bazie danych. Jeśli Twoje tabele nie posiadają prefiksów, Pozostaw tą wartość pustą.
port (opcjonalnie) Port TCP dla Unix do połączenia z serwerem.
encoding Ustawia kodowanie znaków używanych przez bazę danych.
schema Używane w bazie PostgreSQL ustawia jakiego schematu używać.

Opcja prefix jest dla tabel, NIE modeli. Dla przykładu jeśli Tworzysz tabelę spajającą Twoje modele Apple i Flavour , nazwij je prefix_apples_flavors (NIE prefix_apples_prefix_flavors), i ustaw swój prefix na 'prefix_'.

Możesz także zajrzeć CakePHP-Conventions. Poprawne nazewnictwo Twoich tabel (i dodatkowych tabel) możesz zyskać swobodnej funkcjonalności i pomoże Ci ustrzec się od konfiguracji. Przykładowo jeśli nazwiesz swoją tabelę bazy danych big_boxes, model BigBox, kontroler BigBoxesController, wszystko będzie działać razem automatycznie. Używaj podkreśleń, małych liter, liczb mnogich dla Twoich baz danych. Przykład: bakers, pastry_stores, i savory_cakes.

{EN} - 3.4.1 Database Configuration

CakePHP expects database configuration details to be in a file at app/config/database.php. An example database configuration file can be found at app/config/database.php.default. A finished configuration should look something like this.

var $default = array('driver'      => 'mysql',
                     'persistent'  => false,
                     'host'        => 'localhost',
                     'login'       => 'cakephpuser',
                     'password'    => 'c4k3roxx!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');
  1. var $default = array('driver' => 'mysql',
  2. 'persistent' => false,
  3. 'host' => 'localhost',
  4. 'login' => 'cakephpuser',
  5. 'password' => 'c4k3roxx!',
  6. 'database' => 'my_cakephp_project',
  7. 'prefix' => '');

The $default connection array is used unless another connection is specified by the $useDbConfig property in a model. For example, if my application has an additional legacy database in addition to the default one, I could use it in my models by creating a new $legacy database connection array similar to the $default array, and by setting var $useDbConfig = ‘legacy’; in the appropriate models.

Fill out the key/value pairs in the configuration array to best suit your needs.

Key Value
driver The name of the database driver this configuration array is for. Examples: mysql, postgres, sqlite, pear-drivername, adodb-drivername, mssql, oracle, or odbc.
persistent Whether or not to use a persistent connection to the database.
host The database server’s hostname (or IP address).
login The username for the account.
password The password for the account.
database The name of the database for this connection to use.
prefix (optional) The string that prefixes every table name in the database. If your tables don’t have prefixes, set this to an empty string.
port (optional) The TCP port or Unix socket used to connect to the server.
encoding Indicates what character set the to use to send SQL statements to the server.
schema Used in PostgreSQL database setups to specify which schema to use.

The prefix setting is for tables, not models. For example, if you create a join table for your Apple and Flavor models, you name it prefix_apples_flavors (not prefix_apples_prefix_flavors), and set your prefix setting to 'prefix_'.

At this point, you might want to take a look at the CakePHP Conventions. The correct naming for your tables (and the addition of some columns) can score you some free functionality and help you avoid configuration. For example, if you name your database table big_boxes, your model BigBox, your controller BigBoxesController, everything just works together automatically. By convention, use underscores, lower case, and plural forms for your database table names - for example: bakers, pastry_stores, and savory_cakes.

Differences

Lines: 1-7Lines: 1-7
-<title>Database Configuration</title>
<p>
CakePHP expects database configuration details to be in a file at app/config/database.php. An example database configuration file can be found at app/config/database.php.default. A finished configuration should look something like this.
+<title>Konfiguracja bazy danych</title>
<p>Cake PHP używa konfiguracji bazy danych zapisanej w pliku app/config/database.php. />Przykładowy plik konfiguracyjny można znaleźć w app/config/database.php.default. Końcowa konfiguracja powinna wygląd mniej więcej tak:
 </p> </p>
 <pre> <pre>
 var $default = array('driver' =&gt; 'mysql', var $default = array('driver' =&gt; 'mysql',
  'persistent' =&gt; false,  'persistent' =&gt; false,
Lines: 10-114Lines: 10-100
  'password' =&gt; 'c4k3roxx!',  'password' =&gt; 'c4k3roxx!',
  'database' =&gt; 'my_cakephp_project',  'database' =&gt; 'my_cakephp_project',
  'prefix' =&gt; '');  'prefix' =&gt; '');
 </pre> </pre>
-<p><br /> The $default connection array is used unless another connection is specified by the $useDbConfig property in a model. For example, if my application has an additional legacy database in addition to the default one, I could use it in my models by creating a new $legacy database connection array similar to the $default array, and by setting var $useDbConfig = legacy’; in the appropriate models.
</p>
<p>
F
ill out the key/value pairs in the configuration array to best suit your needs.
</p>
+<p>Tablica $default jest używana dopóki inne połączenie nie jest zdefiniowane we właściwości $useDbConfig w modelu. Dla przykładu jeśli nasza aplikacja wykorzystuje dodatko ba danych nie użytą w tablicy $default. Możemy użyć jej w naszym modelu przez stworzenie nowego połączenia z bazą danych $legacy na podobnej zasadzie co nasza tablica $default przez ustawienie <br />var $useDbConfig = 'legacy' w wykorzystywanym modelu.</p>
<p>Wypełnij pary klucz/wartość w tablicy konfiguracyjnej w takiej postaci jakiej potrzebujesz</p>
 <table> <table>
- <tr>
<th>
Key
</th>
<th>
V
aluer /> </th>
</tr>
<tr>
<td>
driver
</td>
<td> /> The name of the database driver this configuration array is for. Examples: mysql, postgres, sqlite, pear-drivername, adodb-drivername, mssql, oracle, or odbc.
</td>
</tr>
<tr>
<td>
persistent
</td>
<td> /> Whether or not to use a persistent connection to the database.
</td>
</tr>
<tr>
+<tr>
<th>Klucz</th>
<th>Wartość</th>
</tr>
<tr>
<td>driver</td>
<td>Nazwa sterownika bazy danych dla którego ta tablica konfiguracyjna jest stworzona. /> Przykład: mysql, postgres, sqlite, pear-drivername, adodb-drivername, mssql, oracle, lub odbc.
</td>
</tr>
<td>persistent</td>
<td>Używa czy nie, stego połączenia z bazą dancych</td>
</tr>
<tr>
  <td>  <td>
  host  host
  </td>  </td>
  <td>  <td>
- The database server’s hostname (or IP address). + Host serwera bazy danych (lub adres IP).
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  login  login
  </td>  </td>
  <td>  <td>
- The username for the account. + Nazwa użytkownika dla konta
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  password  password
  </td>  </td>
  <td>  <td>
- The password for the account. + Hasło użytkownika do konta
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  database  database
  </td>  </td>
  <td>  <td>
- The name of the database for this connection to use. + Nazwa bazy danych
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
- prefix (<em>optional</em>) + prefix (<em>opcjonalnie</em>)
  </td>  </td>
  <td>  <td>
- The string that prefixes every table name in the database. If your tables don’t have prefixes, set this to an empty string. + ciąg znaków który poprzedza wszystkie nazwy tabel w bazie danych. Jeśli Twoje tabele nie posiadają prefiksów, Pozostaw tą wartość pustą.
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
- port (<em>optional</em>) + port (<em>opcjonalnie</em>)
  </td>  </td>
  <td>  <td>
- The TCP port or Unix socket used to connect to the server. + Port TCP dla Unix do połączenia z serwerem.
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  encoding  encoding
  </td>  </td>
  <td>  <td>
- Indicates what character set the to use to send SQL statements to the server. + Ustawia kodowanie znaków używanych przez bazę danych.
  </td>  </td>
  </tr>  </tr>
  <tr>  <tr>
  <td>  <td>
  schema  schema
  </td>  </td>
  <td>  <td>
- Used in PostgreSQL database setups to specify which schema to use. + Używane w bazie PostgreSQL ustawia jakiego schematu używać.
  </td>  </td>
  </tr>  </tr>
 </table> </table>
-<p class="note">The prefix setting is for tables, <strong>not</strong> models. For example, if you create a join table for your Apple and Flavor models, you name it prefix_apples_flavors (<strong>not</strong> prefix_apples_prefix_flavors), and set your prefix setting to 'prefix_'.</p> 
-<p> 
- At this point, you might want to take a look at the <a href="/view/22/cakephp-conventions">CakePHP Conventions</a>. The correct naming for your tables (and the addition of some columns) can score you some free functionality and help you avoid configuration. For example, if you name your database table big_boxes, your model BigBox, your controller BigBoxesController, everything just works together automatically. By convention, use underscores, lower case, and plural forms for your database table names - for example: bakers, pastry_stores, and savory_cakes. 
-</p> 
 +<p class="note">Opcja prefix jest dla tabel, <strong>NIE</strong> modeli. Dla przykładu jeśli Tworzysz tabelę spajającą Twoje modele Apple i Flavour , nazwij je prefix_apples_flavors (<strong>NIE</strong> prefix_apples_prefix_flavors), i ustaw swój prefix na 'prefix_'.</p>
 +<p>Możesz także zajrzeć <a href="pl/view/22/CakePHP-Conventions">CakePHP-Conventions</a>. Poprawne nazewnictwo Twoich tabel (i dodatkowych tabel) możesz zyskać swobodnej funkcjonalności i pomoże Ci ustrzec się od konfiguracji. Przykładowo jeśli nazwiesz swoją tabelę bazy danych big_boxes, model BigBox, kontroler BigBoxesController, wszystko będzie działać razem automatycznie. Używaj podkreśleń, małych liter, liczb mnogich dla Twoich baz danych. Przykład: bakers, pastry_stores, i savory_cakes.
 +</p>