File:  [parser3project] / parser3 / src / include / pa_sql_connection.h
Revision 1.9: download - view: text, annotated - select for diffs - revision graph
Thu May 17 13:23:28 2001 UTC (25 years, 6 months ago) by parser
Branches: MAIN
CVS tags: HEAD
fixed problem at last: 2connections own 1driver and set_services fight for driver::fservices. before fix

/** @file
	Parser: sql fconnection decl.

	Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)

	Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)

	$Id: pa_sql_connection.h,v 1.9 2001/05/17 13:23:28 parser Exp $
*/

#ifndef PA_SQL_CONNECTION_H
#define PA_SQL_CONNECTION_H

#include "pa_config_includes.h"
#include "pa_pool.h"
#include "pa_sql_driver.h"
#include "pa_sql_driver_manager.h"

/// SQL fconnection. handy wrapper around low level SQL_Driver
class SQL_Connection : public Pooled {

public:

	SQL_Connection(Pool& pool, const String& aurl, SQL_Driver& adriver) : Pooled(pool),
		furl(aurl),
		fdriver(adriver) {
	}
	void set_services(SQL_Driver_services *aservices) {
		fservices=aservices;
	}

	void close() {
		SQL_driver_manager->close_connection(furl, *this);
	}

	void connect(char *used_only_in_connect_url_cstr) { 
		fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection);
	}
	void disconnect() { fdriver.disconnect(*fservices, fconnection); }
	void commit() { fdriver.commit(*fservices, fconnection); }
	void rollback() { fdriver.rollback(*fservices, fconnection); }
	bool ping() { return fdriver.ping(*fservices, fconnection); }
	uint quote(char *to, const char *from, unsigned int length) {
		return fdriver.quote(*fservices, fconnection, to, from, length);
	}

	void query(
		const char *statement, unsigned long offset, unsigned long limit,
		unsigned int *column_count, SQL_Driver::Cell **columns,
		unsigned long *row_count, SQL_Driver::Cell ***rows) { 
		fdriver.query(*fservices, fconnection, 
			statement, offset, limit, 
			column_count, columns,
			row_count, rows);
	}


private:

	const String& furl;
	SQL_Driver& fdriver;
	SQL_Driver_services *fservices;
	void *fconnection;
};

#endif

E-mail: