|
|
| version 1.7, 2001/05/17 10:22:24 | version 1.14, 2001/10/22 16:44:42 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: sql connection decl. | Parser: sql fconnection decl. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) |
| $Id$ | $Id$ |
| Line 21 class SQL_Connection : public Pooled { | Line 20 class SQL_Connection : public Pooled { |
| public: | public: |
| void set_services(SQL_Driver_services *services) { | SQL_Connection(Pool& pool, const String& aurl, SQL_Driver& adriver) : Pooled(pool), |
| fdriver.set_services(services); | |
| } | |
| SQL_Connection(Pool& pool, | |
| const String& aurl, | |
| SQL_Driver& adriver, SQL_Driver_services& services, | |
| char *used_only_in_constructor_url_cstr) : Pooled(pool), | |
| furl(aurl), | furl(aurl), |
| fdriver(adriver) { | fdriver(adriver), |
| fconnection(0), | |
| time_stamp(0) { | |
| } | |
| const String& url() { return furl; } | |
| set_services(&services); // associate with services[request] | void set_services(SQL_Driver_services *aservices) { |
| fdriver.connect(used_only_in_constructor_url_cstr, &connection); | time_stamp=time(0); // they started to use at this time |
| fservices=aservices; | |
| } | |
| bool expired(time_t older_dies) { | |
| return time_stamp<older_dies; | |
| } | } |
| void close() { | void close() { |
| set_services(0); // deassociate from services[request] | |
| SQL_driver_manager->close_connection(furl, *this); | SQL_driver_manager->close_connection(furl, *this); |
| } | } |
| void disconnect() { fdriver.disconnect(connection); } | bool connected() { return fconnection!=0; } |
| void commit() { fdriver.commit(connection); } | void connect(char *used_only_in_connect_url_cstr) { |
| void rollback() { fdriver.rollback(connection); } | fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection); |
| bool ping() { return fdriver.ping(connection); } | } |
| void disconnect() { fdriver.disconnect(fconnection); fconnection=0; } | |
| 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) { | uint quote(char *to, const char *from, unsigned int length) { |
| return fdriver.quote(connection, to, from, length); | return fdriver.quote(*fservices, fconnection, to, from, length); |
| } | } |
| void query( | void query( |
| const char *statement, unsigned long offset, unsigned long limit, | const char *statement, unsigned long offset, unsigned long limit, |
| unsigned int *column_count, SQL_Driver::Cell **columns, | SQL_Driver_query_event_handlers& handlers) { |
| unsigned long *row_count, SQL_Driver::Cell ***rows) { | fdriver.query(*fservices, fconnection, |
| fdriver.query(connection, | |
| statement, offset, limit, | statement, offset, limit, |
| column_count, columns, | handlers); |
| row_count, rows); | |
| } | } |
| private: | private: |
| SQL_Driver& fdriver; | |
| void *connection; | |
| const String& furl; | const String& furl; |
| SQL_Driver& fdriver; | |
| SQL_Driver_services *fservices; | |
| void *fconnection; | |
| time_t time_stamp; | |
| }; | }; |
| #endif | #endif |