Trace:
Differences ¶
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en:tutorials:main:database-config [2007/09/16 06:45] – created laurent | en:tutorials:main:database-config [2008/11/19 21:42] (current) – laurent | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Configuring the database access ====== | ||
| - | Before going further with code, you have to configure Jelix to be able to access a database, and feed this databasea little | + | Before going further with code, you have to configure Jelix to be able to access a database, and feed this database a bit. We will indeed store our news in a table. |
| Jelix can handle mysql, postgresql, sqlite and pdo. Through its driver system, it is possible to add other types of databases (if you don't want to use pdo). | Jelix can handle mysql, postgresql, sqlite and pdo. Through its driver system, it is possible to add other types of databases (if you don't want to use pdo). | ||
| - | |||
| - | |||
| ===== Access configuration file ===== | ===== Access configuration file ===== | ||
| - | The access to a database is configured in the actu.org/ | + | The access to a database is configured in the news.org/ |
| - | Each profile has a name and is | + | Each profile has a name and are specified like this : |
| <code ini> | <code ini> | ||
| [ProfileName] | [ProfileName] | ||
| driver=" | driver=" | ||
| - | database=" | + | database=" |
| - | host= " | + | host= " |
| - | user= " | + | user= " |
| password=" | password=" | ||
| - | persistent= on ; indicating if the connexion | + | persistent= on ; indicating if the connection |
| + | force_encoding = off; | ||
| </ | </ | ||
| - | Except the dirver | + | Except the driver |
| + | |||
| + | Now change | ||
| <code ini> | <code ini> | ||
| - | default = actu.org | + | default = news.org |
| - | [actu.org] | + | [news.org] |
| driver=" | driver=" | ||
| - | database=" | + | database=" |
| host= " | host= " | ||
| - | user= "actu" | + | user= "admin" |
| - | password=" | + | password=" |
| persistent= on | persistent= on | ||
| </ | </ | ||
| - | Check in the actu.org/ | + | |
| + | Note: It is indeed sometimes interesting to have several entry points, then several settings sharing | ||
| <code ini> | <code ini> | ||
| - | | + | |
| </ | </ | ||
| - | |||
| - | It is indeed sometimes interesting to have several entrance points, then several | ||
| - | |||
| ===== Creation of the table ===== | ===== Creation of the table ===== | ||
| - | In the "actu" | + | In the "news" |
| <code sql> | <code sql> | ||
| CREATE TABLE `news` ( | CREATE TABLE `news` ( | ||
| - | `id_news` INT NOT NULL AUTO_INCREMENT , | + | `news_id` INT NOT NULL AUTO_INCREMENT , |
| `subject` VARCHAR( 255 ) NOT NULL , | `subject` VARCHAR( 255 ) NOT NULL , | ||
| `text` TEXT NOT NULL , | `text` TEXT NOT NULL , | ||
| `news_date` DATE NOT NULL , | `news_date` DATE NOT NULL , | ||
| - | PRIMARY KEY ( `id_news` ) | + | PRIMARY KEY ( `news_id` ) |
| ); | ); | ||
| </ | </ | ||
| - | And feed this table avec deux news (we will make a form later). | + | And feed this table with two news (we will make a form later). |
| <code sql> | <code sql> | ||
| Line 72: | Line 70: | ||
| We are now ready to use this data in our application. | We are now ready to use this data in our application. | ||
| - | ---- | ||
| - | * Next : [[en: | ||
| - | * Previous : [[en: | ||
| - | * [[en: | ||

