v5:reference:connection:adonewconnection
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
reference:adonewconnection [2015/07/26 18:09] – [Error Codes] mnewnham | v5:reference:connection:adonewconnection [2020/12/08 10:39] (current) – better use PHP string concatenation for example instead of javascript's ;-) peterdd | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== adoNewConnection ====== | ====== adoNewConnection ====== | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
- | <WRAP alert> | ||
- | Not passing a driver name as the parameter to this function does nothing but return an html string indication that the no driver name was passed. This behavior will be removed in version 6.0.0. | ||
- | </ | ||
- | <WRAP alert> | ||
- | Passing an invalid or missing driver name as the parameter to this function returns an html formatted string. This behavior will be change in version 6.0.0. If an error occurs, the function will return a numeric error. See the guide below. | ||
- | </ | ||
<WRAP right box> | <WRAP right box> | ||
- | == Syntax | + | == Syntax == |
- | + | ||
mixed adoNewConnection( | mixed adoNewConnection( | ||
optional string $driverType='' | optional string $driverType='' | ||
) | ) | ||
- | + | ||
- | == Syntax version 6.0.0 == | + | |
- | mixed adoNewConnection( | + | |
- | string $driverType | + | |
- | ) | + | |
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
Line 31: | Line 21: | ||
** | ** | ||
- | If the DSN string parses correctly, an attempt is made to automatically connect to the database. If the connection succeeds, then there is no need to issue a [[reference: | + | If the DSN string parses correctly, an attempt is made to automatically connect to the database. If the connection succeeds, then there is no need to issue a [[v5:reference:connection: |
+ | ===== Usage ===== | ||
+ | ==== Simple Usage ==== | ||
+ | <code php> | ||
+ | include ' | ||
+ | /* | ||
+ | * Simple connection | ||
+ | */ | ||
+ | $driver = ' | ||
+ | $db = adoNewConnection($driver); | ||
+ | /* | ||
+ | * Now connect to the database | ||
+ | */ | ||
+ | $db-> | ||
+ | </ | ||
+ | ==== DSN Usage ==== | ||
+ | <code php> | ||
+ | include ' | ||
+ | /* | ||
+ | * Set DSN | ||
+ | */ | ||
+ | $driver = ' | ||
+ | $DSN = " | ||
+ | $db = adoNewConnection($driver . '://' | ||
+ | /* | ||
+ | * Now connected | ||
+ | */ | ||
+ | </ | ||
+ | ===== Additional Parameters To DSN connection ==== | ||
+ | The following additional parameter can be added to the DSN connection string. Some of the parameters only work with specific drivers. | ||
- | ===== Error Codes ===== | + | ^ Code ^ Driver |
- | As of version 6.0.0 , the following error codes will be returned if a connection | + | | new |
+ | | persist | ||
+ | | persistent | ||
+ | | debug | ||
+ | | port | mysqli, postgres9 | ||
+ | | socket | ||
+ | | nls_date_format | ||
+ | | cachesecs | ||
+ | | memCache | ||
+ | | memCacheHost | ||
+ | | memCachePort | ||
+ | | memCacheCompress | ||
- | ^Code^Description^ | + | ===== Error Codes ===== |
- | |-1|An invalid driver name was given| | + | Note that, because no connection object is available, the codes cannot be retrieved |
- | |-2|Unable to parse DSN string| | + | |
- | |-3|Connection to database | + | |
- | Note that, because no connection object is available, the codes cannot be retrieved via [[reference: | ||
v5/reference/connection/adonewconnection.txt · Last modified: 2020/12/08 10:39 by peterdd