Auth_OpenID_SQLStore::__construct PHP Метод

__construct() публичный Метод

This creates a new SQLStore instance. It requires an established database connection be given to it, and it allows overriding the default table names.
public __construct ( connection $connection, $associations_table = null, $nonces_table = null )
$connection connection This must be an established connection to a database of the correct type for the SQLStore subclass you're using. This must either be an PEAR DB connection handle or an instance of a subclass of Auth_OpenID_DatabaseConnection.
    function __construct($connection, $associations_table = null, $nonces_table = null)
    {
        $this->associations_table_name = "oid_associations";
        $this->nonces_table_name = "oid_nonces";
        // Check the connection object type to be sure it's a PEAR
        // database connection.
        if (!(is_object($connection) && (is_subclass_of($connection, 'db_common') || is_subclass_of($connection, 'auth_openid_databaseconnection')))) {
            trigger_error("Auth_OpenID_SQLStore expected PEAR connection " . "object (got " . get_class($connection) . ")", E_USER_ERROR);
            return;
        }
        $this->connection = $connection;
        // Be sure to set the fetch mode so the results are keyed on
        // column name instead of column index.  This is a PEAR
        // constant, so only try to use it if PEAR is present.  Note
        // that Auth_Openid_Databaseconnection instances need not
        // implement ::setFetchMode for this reason.
        if (is_subclass_of($this->connection, 'db_common')) {
            $this->connection->setFetchMode(DB_FETCHMODE_ASSOC);
        }
        if ($associations_table) {
            $this->associations_table_name = $associations_table;
        }
        if ($nonces_table) {
            $this->nonces_table_name = $nonces_table;
        }
        $this->max_nonce_age = 6 * 60 * 60;
        // Be sure to run the database queries with auto-commit mode
        // turned OFF, because we want every function to run in a
        // transaction, implicitly.  As a rule, methods named with a
        // leading underscore will NOT control transaction behavior.
        // Callers of these methods will worry about transactions.
        $this->connection->autoCommit(false);
        // Create an empty SQL strings array.
        $this->sql = array();
        // Call this method (which should be overridden by subclasses)
        // to populate the $this->sql array with SQL strings.
        $this->setSQL();
        // Verify that all required SQL statements have been set, and
        // raise an error if any expected SQL strings were either
        // absent or empty.
        list($missing, $empty) = $this->_verifySQL();
        if ($missing) {
            trigger_error("Expected keys in SQL query list: " . implode(", ", $missing), E_USER_ERROR);
            return;
        }
        if ($empty) {
            trigger_error("SQL list keys have no SQL strings: " . implode(", ", $empty), E_USER_ERROR);
            return;
        }
        // Add table names to queries.
        $this->_fixSQL();
    }