| version 1.1, 2003/04/21 23:50:20 |
version 1.2, 2003/04/22 14:19:52 |
|
|
| /** |
/** |
| * Data source name (DSN) parsing implementation. |
* Data source name (DSN) parsing implementation |
| * |
* |
| * @file platon/dsn/dsn.h |
* @file platon/dsn/dsn.h |
| * @author Peter Rockai <yenar@platon.sk> |
* @author Peter Rockai <yenar@platon.sk> |
| * @version \$Platon: libplaton/platon/str/strplus.h,v 1.22 2002/12/04 18:18:39 nepto Exp $ |
* @version \$Platon: libplaton/platon/dsn/dsn.h,v 1.1 2003/04/21 23:50:20 nepto Exp $ |
| * @date 1997-2002 |
* @date 2003 |
| */ |
|
| |
Data source name (DSN) is URL-like string used for uniquely defining data |
| |
sources (especially relational database managment systems). |
| |
|
| |
To connect to a database through interface using data source name (DSN) as a |
| |
source specification, you have to create a valid DSN. This DSN consists in |
| |
the following parts: |
| |
|
| |
@verbatim |
| |
phptype: Database backend used in PHP (i.e. mysql, odbc etc.) |
| |
dbsyntax: Database used with regards to SQL syntax etc. |
| |
protocol: Communication protocol to use (i.e. tcp, unix etc.) |
| |
hostspec: Host specification (hostname[:port]) |
| |
database: Database to use on the DBMS server |
| |
username: User name for login |
| |
password: Password for login |
| |
proto_opts: Maybe used with protocol |
| |
@endverbatim |
| |
|
| |
The format of the supplied DSN is in its fullest form: |
| |
|
| |
@verbatim |
| |
phptype(dbsyntax)://username:password@protocol+hostspec/database |
| |
@endverbatim |
| |
|
| |
Most variations are allowed: |
| |
|
| |
@verbatim |
| |
phptype://username:password@protocol+hostspec:110//usr/db_file.db |
| |
phptype://username:password@hostspec/database_name |
| |
phptype://username:password@hostspec |
| |
phptype://username@hostspec |
| |
phptype://hostspec/database |
| |
phptype://hostspec |
| |
phptype(dbsyntax) |
| |
phptype |
| |
@endverbatim |
| |
|
| |
You can also use a second DSN format: |
| |
|
| |
@verbatim |
| |
phptype(syntax)://user:pass@protocol(proto_opts)/database |
| |
@endverbatim |
| |
|
| |
Example 1: connect to database through a socket |
| |
@verbatim |
| |
mysql://user@unix(/path/to/socket)/pear |
| |
@endverbatim |
| |
|
| |
Example 2: connect to database on a non standard port |
| |
@verbatim |
| |
pgsql://user:pass@word@tcp(localhost:5555)/pear |
| |
@endverbatim |
| |
*/ |
| |
|
| #ifndef _PLATON_DSN_DSN_H |
#ifndef _PLATON_DSN_DSN_H |
| #define _PLATON_DSN_DSN_H |
#define _PLATON_DSN_DSN_H |
|
|
| #endif |
#endif |
| |
|
| /** |
/** |
| * TODO |
* Structure with data source name (DSN) elements. When parsing DSN |
| |
* string, extracted options are stored here. |
| |
* |
| |
* @struct dsn_elements <platon/dsn/dsn.h> |
| |
* @author Ondrej Jombik <nepto@platon.sk> |
| |
* @version \$Platon: libplaton/platon/net/Connection.h,v 1.13 2002/12/07 15:36:32 rajo Exp $ |
| |
* @date 2002-2003 |
| */ |
*/ |
| struct dsn_elements |
struct dsn_elements |
| { |
{ |
|
|
| }; |
}; |
| |
|
| /** |
/** |
| * TODO |
* Frees dsn_elements structure members |
| |
* |
| |
* @param el pointer to dsn_elements structure |
| |
* @return void |
| |
* @author Ondrej Jombik <nepto@platon.sk> |
| */ |
*/ |
| void dsn_free(struct dsn_elements *el); |
void dsn_free(struct dsn_elements *el); |
| |
|
| /** |
/** |
| * TODO |
* Parses DSN string into dsn_elements structure |
| |
* |
| |
* @param input_dsn data source name (DSN) string |
| |
* @retval el pointer to dsn_elements structure |
| |
* @return 1 on success, 0 on memory failure error |
| |
* @author Peter Rockai <yenar@platon.sk> |
| */ |
*/ |
| int dsn_parse(const char *input_dsn, struct dsn_elements *el); |
int dsn_parse(const char *input_dsn, struct dsn_elements *el); |
| |
|
|
|
| |
|
| #endif /* #ifndef _PLATON_DSN_DSN_H */ |
#endif /* #ifndef _PLATON_DSN_DSN_H */ |
| |
|
| |
|