README
1Horde_Db
2
3Horde_Db provides database connection abstraction and SQL compatibility tools for a number of database systems and PHP extensions. It currently supports the following databases and extensions:
4
5+-------------+----------+
6|Database |Extension |
7+-------------+----------+
8|MySQL/MariaDB|mysql |
9| +----------+
10| |mysqli |
11| +----------+
12| |PDO_mysql |
13+-------------+----------+
14|PostgreSQL |PDO_pgsql |
15+-------------+----------+
16|SQLite |PDO_sqlite|
17+-------------+----------+
18|Oracle |oci8 |
19+-------------+----------+
20
21Advanced features include:
22
23- Connection abstraction
24- SQL compatibility tools
25- Database schema management
26- Master/server configuration with queries split to write and read instances
27- BLOB/CLOB handling
28- Caching
29- Query logging
30
31Connection management
32
33Connecting to a database is as simple as instantiating a class implementing the Horde_Db_Adapter interface, providing the necessary connection parameters:
34
35MySQL
36
37Please note that the mysql PHP extension is deprecated as of PHP 7, as is the Horde_Db_Adapter_Mysql backend.
38
39$config = [
40 'host' => 'localhost',
41 'username' => 'user',
42 'password' => 'secret',
43 'database' => 'db',
44];
45$db = new Horde_Db_Adapter_Mysqli($config);
46$db = new Horde_Db_Adapter_Pdo_Mysql($config);
47$db = new Horde_Db_Adapter_Mysql($config);
48
49Full list of connection parameters:
50
51+---------------+---------+--------------------------------------+
52|Parameter |Mandatory|Meaning |
53+---------------+---------+--------------------------------------+
54|charset | |Connection character set |
55+---------------+---------+--------------------------------------+
56|database/dbname| |Database name |
57+---------------+---------+--------------------------------------+
58|host | |Host name, if using TCP connection (1)|
59+---------------+---------+--------------------------------------+
60|port | |Port number, if using TCP connection |
61+---------------+---------+--------------------------------------+
62|socket | |Socket location, if using Unix sockets|
63+---------------+---------+--------------------------------------+
64|username |X |Database user |
65+---------------+---------+--------------------------------------+
66
67.:1 To workaround MySQL automatically using the unix socket if setting the host to 'localhost', the hostname will be translated from 'localhost' to '127.0.0.1' if using the TCP protocol
68
README_TESTING
1=====================
2 Horde/Db Test Suite
3=====================
4
5:Authors: Chuck Hagenbuch
6:Authors: Jan Schneider
7:Contact: dev@lists.horde.org
8
9.. contents:: Contents
10.. section-numbering::
11
12Defining adapters
13=================
14
15As long as PHP has the PDO SQLite driver (which is enabled by default), the
16SQLite tests will always be run. This is possible using the sqlite:memory
17database; no file access or permissions are required.
18
19For the other adapters, the Horde_Db test suite looks for the configuration
20file conf.php, with an example configuration found at the conf.php.dist file,
21or for environment variables named DB_ADAPTER_$driverName_TEST_CONFIG. For the
22MySQLi driver, that would be DB_ADAPTER_MYSQLI_TEST_CONFIG. For the PDO
23PostgreSQL driver, that would be DB_ADAPTER_PDO_PGSQL_TEST_CONFIG, and so
24on. The value of the environment variable is a JSON string with the
25configuration array for the adapter. Here is an example for setting up a test
26DSN for the MySQL test database on localhost, connecting as the user horde_db
27with no password:
28
29{"username":"horde_db","dbname":"test","host":"localhost"}
30
31When running the test suite, any adapter for which a DSN is not found, or for
32which connecting to the defined DSN fails, a single instance of
33Horde_Db_Adapter_MissingTest will be included in the test suite run, with
34details on why the adapter was skipped.
35