1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
* Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KJSEMBED_SQL_IMP_H
#define KJSEMBED_SQL_IMP_H
#include "bindingobject.h"
#include <tqsqlquery.h>
#include <tqsqldatabase.h>
namespace KJSEmbed {
namespace Bindings {
/**
* TTQObject Binding for TQSQLQuery.
*
* @author Ian Reinhart Geiser, geiseri@kde.org
* @version $Id$
*/
class SqlQuery : public BindingObject
{
Q_OBJECT
Q_PROPERTY( int size READ size)
Q_PROPERTY( int at READ at)
Q_PROPERTY( int numRowsAffected READ numRowsAffected )
Q_PROPERTY( bool select READ isSelect)
Q_PROPERTY( bool valid READ isValid)
Q_PROPERTY( bool active READ isActive)
Q_PROPERTY( TTQString lastError READ lastError)
Q_PROPERTY( TTQString lastQuery READ lastQuery)
public:
SqlQuery( TTQObject *parent=0, const char *name=0 );
SqlQuery( TTQObject *parent, const char *name, const TTQSqlQuery &q );
//SqlQuery( const SqlQuery ©);
virtual ~SqlQuery();
TTQSqlQuery query(){ return m_query; }
void setQuery(const TTQSqlQuery &q) {m_query = TTQSqlQuery(q); }
int size () const;
bool isSelect () const;
bool isValid () const;
bool isActive () const;
int at () const;
int numRowsAffected () const;
TTQString lastError () const;
TTQString lastQuery () const;
public slots:
bool isNull ( int field );
bool exec ( const TTQString & m_query );
TTQVariant value ( int i );
bool seek ( int i, bool relative = FALSE );
bool next ();
bool prev ();
bool first ();
bool last ();
private:
TTQSqlQuery m_query;
};
/**
* TTQObject Binding for TQSQLDatabase.
*
* @author Ian Reinhart Geiser, geiseri@kde.org
* @version $Id$
*/
class SqlDatabase : public BindingObject
{
Q_OBJECT
Q_PROPERTY( TTQString databaseName READ databaseName WRITE setDatabaseName)
Q_PROPERTY( TTQString userName READ userName WRITE setUserName)
Q_PROPERTY( TTQString password READ password WRITE setPassword)
Q_PROPERTY( TTQString hostName READ hostName WRITE setHostName)
Q_PROPERTY( int port READ port WRITE setPort)
Q_PROPERTY( TTQString driverName READ driverName)
Q_PROPERTY( TTQString lastError READ lastError)
public:
SqlDatabase( TTQObject *parent=0, const char *name=0 );
virtual ~SqlDatabase();
public slots:
void setDatabaseName (const TTQString &name );
void setUserName (const TTQString &name );
void setPassword (const TTQString &password );
void setHostName (const TTQString &host );
void setPort ( int p );
TTQString databaseName () const;
TTQString userName () const;
TTQString password () const;
TTQString hostName () const;
int port () const;
TTQString driverName () const;
bool addDatabase ( const TTQString & type, const TTQString & connectionName = TTQSqlDatabase::defaultConnection );
TTQStringList drivers ();
bool open ();
bool open ( const TTQString &user, const TTQString &password );
void close ();
bool isOpen ();
bool isOpenError ();
TTQStringList tables ();
SqlQuery *exec( const TTQString &query );
TTQString lastError () const;
bool transaction ();
bool commit ();
bool rollback ();
private:
TTQString connectionName;
//TTQSqlDatabase *db;
};
} // namespace KJSEmbed::Bindings
} // namespace KJSEmbed
#endif // KJSEMBED_SQL_IMP_H
|