mysql://user:password@host[:port]|[/unix/socket]/database?
charset=value&[value must be conversion for MySQL 3.x/4.0 or character set name for MySQL 4.1+] ClientCharset=charset& timeout=3&
compress=0&
named_pipe=1&
autocommit=1&
multi_statements=0 [3.3.0]
Optional parameters are:
Port is number of port used by database server. One can use:
user:password@hostname:port_number/database.
One can also replace hostname and port_number with path to UNIX socket in square brackets (UNIX socket is a magical set of characters (path), which your administrator may tell you, provided you yourself are not the administrator in the flesh. This socket may be used to communicate with server):
user:password@[/unix/socket]/database
charset-right after connection executes "SET CHARACTER SET value"; ClientCharset-specifies the charset, in which Parser must communicate with SQL server. Conversion will be done by driver;
timeout-specifies value of parameter Connect timeout in seconds;
compress-mode of compressing traffic between server and client;
named_pipe-use named pipes to connect to MySQL-server, working under Windows NT;
autocommit-if set to 0 after connection executes "SET AUTOCOMMIT=0"; multi_statements-if set to 1, the single SQL query can contains more then one SQL statements separated by ";" character (character ";" must be escaped by character "^").
Example: transcoding by SQL server (it works with many character sets but requiresMySQL version 4.1 or higher)
MySQL server version 4.1 or higher can transcode data in different ways itself so it is recommended to use these server abilities using charset option and don't use ClientCharset option at all. With MySQL server version 4.1 or higher you can even store data in different tables using different character sets but we recommend to store it in UTF-8.
Assume, data in your database is stored inUTF-8, while pages are in windows-1257, connect string should look like this:
mysql://user:password@host/database?charset=cp1257
In this case right after connection to the server Parser will executes command "SET CHARACTER SET cp1257" and server will transcode received data from cp1257 to character set used for storing data in requested database/table/column and transcode it back while send response.
Note: in this case you should specify character set used for storing pages. Note: this option executes the MySQL command so you must use MySQL server character set names which are not equal to Parser character set names, defined in configuration file.
Example: DB in koi8-r, pages are in windows-1251, transcoding by SQL server (MySQL 3.x and 4.0)
MySQL server version 3.x and 4.0 can't transcode data in arbitrary ways but can transcode it in most common for Russian language case when data stored in koi8-r, while pages are in windows-1251.
In this case you can also transcode data with driver transcode functions using ClientCharset option (see below), however it's much better to do it using charset option with cp1251_koi8 value:
mysql://user:password@host/database?charset=cp1251_koi8
In this case right after connection to the server Parser will executes command "SET CHARACTER SET cp1251_koi8".
MySQL server version 3.x and 4.0 understands this option in different way, it will transcode receiving data from cp1251 to koi8-r and transcode sending data from koi8-r to cp1251.
Note: for MySQL server version 3.x and 4.0 value defines transcode directions, herewith server is not supported other values, for example koi8_cp1251.
Example: DB in windows-1251, pages are in koi8-r, transcoding by Parser driver (for any version of MySQL server)
In some cases it's unable to use MySQL server transcode functions. In this case you can use driver transcode functions with ClientCharset option.
Assume, data in your database is stored in windows-1251, while pages are in koi8-r, connect string should look like this:
mysql://user:password@host/database?ClientCharset=windows-1251
For Parser code all received data will be automatically converted from windows-1251 to $request:charset (koi8-r in this example).
Note: in this case you should specify character set used for storing data in database. Note: in this option you must use Parser character set names, defined in configuration file.