1<?php
2
3/**
4 * The Auth_OpenID_DatabaseConnection class, which is used to emulate
5 * a PEAR database connection.
6 *
7 * @package OpenID
8 * @author JanRain, Inc. <openid@janrain.com>
9 * @copyright 2005-2008 Janrain, Inc.
10 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
11 */
12
13/**
14 * An empty base class intended to emulate PEAR connection
15 * functionality in applications that supply their own database
16 * abstraction mechanisms.  See {@link Auth_OpenID_SQLStore} for more
17 * information.  You should subclass this class if you need to create
18 * an SQL store that needs to access its database using an
19 * application's database abstraction layer instead of a PEAR database
20 * connection.  Any subclass of Auth_OpenID_DatabaseConnection MUST
21 * adhere to the interface specified here.
22 *
23 * @package OpenID
24 */
25class Auth_OpenID_DatabaseConnection {
26    /**
27     * Sets auto-commit mode on this database connection.
28     *
29     * @param bool $mode True if auto-commit is to be used; false if
30     * not.
31     */
32    function autoCommit($mode)
33    {
34    }
35
36    /**
37     * Run an SQL query with the specified parameters, if any.
38     *
39     * @param string $sql An SQL string with placeholders.  The
40     * placeholders are assumed to be specific to the database engine
41     * for this connection.
42     *
43     * @param array $params An array of parameters to insert into the
44     * SQL string using this connection's escaping mechanism.
45     *
46     * @return mixed $result The result of calling this connection's
47     * internal query function.  The type of result depends on the
48     * underlying database engine.  This method is usually used when
49     * the result of a query is not important, like a DDL query.
50     */
51    function query($sql, $params = [])
52    {
53        return null;
54    }
55
56    /**
57     * Starts a transaction on this connection, if supported.
58     */
59    function begin()
60    {
61    }
62
63    /**
64     * Commits a transaction on this connection, if supported.
65     */
66    function commit()
67    {
68    }
69
70    /**
71     * Performs a rollback on this connection, if supported.
72     */
73    function rollback()
74    {
75    }
76
77    /**
78     * Run an SQL query and return the first column of the first row
79     * of the result set, if any.
80     *
81     * @param string $sql An SQL string with placeholders.  The
82     * placeholders are assumed to be specific to the database engine
83     * for this connection.
84     *
85     * @param array $params An array of parameters to insert into the
86     * SQL string using this connection's escaping mechanism.
87     *
88     * @return mixed $result The value of the first column of the
89     * first row of the result set.  False if no such result was
90     * found.
91     */
92    function getOne($sql, $params = [])
93    {
94        return false;
95    }
96
97    /**
98     * Run an SQL query and return the first row of the result set, if
99     * any.
100     *
101     * @param string $sql An SQL string with placeholders.  The
102     * placeholders are assumed to be specific to the database engine
103     * for this connection.
104     *
105     * @param array $params An array of parameters to insert into the
106     * SQL string using this connection's escaping mechanism.
107     *
108     * @return array|bool $result The first row of the result set, if any,
109     * keyed on column name.  False if no such result was found.
110     */
111    function getRow($sql, $params = [])
112    {
113        return false;
114    }
115
116    /**
117     * Run an SQL query with the specified parameters, if any.
118     *
119     * @param string $sql An SQL string with placeholders.  The
120     * placeholders are assumed to be specific to the database engine
121     * for this connection.
122     *
123     * @param array $params An array of parameters to insert into the
124     * SQL string using this connection's escaping mechanism.
125     *
126     * @return array $result An array of arrays representing the
127     * result of the query; each array is keyed on column name.
128     */
129    function getAll($sql, $params = [])
130    {
131        return [];
132    }
133}
134
135