Data source name: Difference between revisions

Content deleted Content added
Example of use: add reference
WikiCleanerBot (talk | contribs)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
 
(3 intermediate revisions by one other user not shown)
Line 19:
Two kinds of DSN exist:
 
* '''Machine DSNs''' – stored in collective configuration files (e.g., {{code|/etc/odbc.ini}}, {{code|~/.odbc.ini}}) and/or system resources (e.g., Windows Registry {{code|HKLM\Software\ODBC\odbc.ini}})
* '''File DSNs''' – stored in the filesystem with one DSN per file
 
These are further broken down into
* '''System DSNs''' – accessible by any and all processes and users of the system, stored in a centralized ___location (e.g., {{code|/etc/odbc.ini}}, {{code|//etc/odbc_file_dsns/<filename>}})
* '''User DSNs''' – accessible only by the user who created the DSN, stored in a user-specific ___location (e.g., {{code|/~/.odbc.ini}}, {{code|/~/odbc_file_dsns/<filename>}})
 
== Example of use ==
Line 37:
</syntaxhighlight>
 
In [[PHP]] using the [https://pear.php.net/package/DB/ PEAR::DB] package to open a connection without an external DSN (a "DSN-less connection", i.e., using a Connection String){{Clarify|How is this an example of DSN use|date=June 2013}}, the code might resemble the following:
 
<syntaxhighlight lang="php">
Line 44:
$dsn = "mysql://john:pass@localhost:3306/my_db";
$db = DB::connect($dsn);
</syntaxhighlight>{{Clarify|How is this an example of DSN use|date=June 2013}}
 
PHP with PDO.:<ref>{{cite web |title=PHP: PDO - Manual |url=https://www.php.net/pdo |website=www.php.net |access-date=22 January 2025 |language=en}}</ref>
<syntaxhighlight lang="php">
$dsn = "mysql:host=localhost;dbname=example";