pjs/extensions/sql/base/public/mozISqlConnection.idl

155 строки
5.3 KiB
Plaintext

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Jan Varga
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Neil Deakin <enndeakin@sympatico.ca>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface mozISqlResult;
interface mozISqlRequest;
interface mozISqlRequestObserver;
/**
* A connection to a SQL database. This interface may be further extended
* by a particular database implementation. The SQL service is responsible
* for creating and maintaining connections, so there isn't a means to create
* one directly via this interface.
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(f16397a4-1ecb-4e08-84f8-27750c04b779)]
interface mozISqlConnection : nsISupports
{
/**
* A string holding the name and/or version info of the database.
*/
readonly attribute AString serverVersion;
/**
* The most recent error message.
*/
readonly attribute AString errorMessage;
/**
* The ID of the most recently added record.
*/
readonly attribute long lastID;
/**
* Set up the connection. This is called by the SQL service. There is no
* need to call this method directly.
*
* @param aHost the host name.
* @param aPort the port at which the host is listening.
* @param aDatabase the real database name to connect to.
* @param aUsername the username to connect as.
* @param aPassword the password to use in authentification phase.
*/
void init(in AString aHost,
in long aPort,
in AString aDatabase,
in AString aUsername,
in AString aPassword);
/**
* Execute an SQL query synchronously and return the query result.
*
* @param aQuery the SQL string of the query to execute
* @return the result of the query
*/
mozISqlResult executeQuery(in AString aQuery);
/**
* Execute an SQL update synchronously and return the number of updated
* rows.
*
* @param aUpdate the update to execute
* @return the result of the query
*/
long executeUpdate(in AString aUpdate);
/**
* Execute an SQL query asynchronously and return a request. An observer
* may be used to track when the query has completed.
*
* @param aQuery the SQL string of the query to execute
* @param aContext extra argument that will be passed to the observer
* @param aObserver observer that will be notified when the query is done
* @return a request object
*/
mozISqlRequest asyncExecuteQuery(in AString aQuery,
in nsISupports aContext,
in mozISqlRequestObserver aObserver);
/**
* Execute an SQL update asynchronously and return a request. An observer
* may be used to track when the query has completed.
*
* @param aQuery the SQL string of the update to execute
* @param aContext extra argument that will be passed to the observer
* @param aObserver observer that will be notified when the update is done
* @return a request object
*/
mozISqlRequest asyncExecuteUpdate(in AString aQuery,
in nsISupports aContext,
in mozISqlRequestObserver aObserver);
/**
* Begin a transaction. Updates made during the transaction will not be
* made permanent until it is committed using commitTransaction.
*/
void beginTransaction();
/**
* Commit the current transaction
*/
void commitTransaction();
/**
* Rollback (cancel) the current transaction
*/
void rollbackTransaction();
/**
* Return the primary keys of a given table.
*
* @param aSchema the schema
* @param aTable the table name of the keys to retrieve
* @return the result which holds the keys
*/
mozISqlResult getPrimaryKeys(in AString aSchema, in AString aTable);
};