8 class smartQuery: public QSqlQuery9 {10 //Q_OBJECT11 private:12 QString query;13 QString order;14 QStringList keys;15 QVariantList values;16 Debugger *dbg;17 18 public:19 smartQuery ( QSqlResult * );20 smartQuery ( const QString &query = QString(), QSqlDatabase db = QSqlDatabase());21 smartQuery ( QSqlDatabase db);22 smartQuery ( const QSqlQuery & other);23 24 bool exec (const QString str);25 26 void addKey (QString key);27 void addValue (QString key, const QVariant value);28 void setOrder (QString key);29 30 void select (QString table,31 /* WHERE */32 QString key = QString(),33 QVariant value = QVariant(),34 QString sign = QString()35 );36 void insert (QString table);37 void update (QString table, /* WHERE */ QString key, QVariant value);38 void remove (QString table, /* WHERE */ QString key, QVariant value);39 };
24 bool smartQuery::exec (const QString str) 25 { 26 bool result = false; 27 28 keys.clear(); 29 values.clear(); 30 order.clear(); 31 32 dbg->sql(str); 33 //clear (); 34 dbg->sql(str); 35 36 //QSqlQuery::prepare(str); 37 //result = QSqlQuery::exec(); 38 result = QSqlQuery::exec(str); 39 40 if (lastError().isValid()) 41 { 42 dbg->wrn(lastError().text()); 43 result = false; 44 } 45 return result; 46 }
smartQuery sq;sq.exec("SELECT * FROM table");
32 dbg->sql(str); 33 //clear (); 34 dbg->sql(str); 35 36 //QSqlQuery::prepare(str); 37 //result = QSqlQuery::exec(); 38 result = QSqlQuery::exec(str);
Program received signal SIGSEGV, Segmentation fault.[Switching to Thread -1225332512 (LWP 16800)]0xb6b79cf3 in mysql_next_result () from /usr/lib/libmysqlclient_r.so.15
24 bool smartQuery::exec (const QString str)
bool QSqlQuery::exec( const QString & str );
24 bool smartQuery::exec () 25 { 26 return QSqlQuery::exec(); 27 }
../smartQuery/src/smartQuery.h:9: предупреждение: ‘class smartQuery’ has virtual functions but non-virtual destructor
undefined reference to `smartQuery::~smartQuery()'
59 QSqlQuery(QSqlResult *r); 60 QSqlQuery(const QString& query = QString(), QSqlDatabase db = QSqlDatabase()); 61 explicit QSqlQuery(QSqlDatabase db); 62 QSqlQuery(const QSqlQuery& other); 63 QSqlQuery& operator=(const QSqlQuery& other); 64 ~QSqlQuery();
smartQuery( const smartQuery & );smartQuery &operator=( const smartQuery & );
smartQuery &operator=( const smartQuery & other){ swap(other); return *this;}
smartQuery &TestQuery::operator=( const smartQuery &query ){ *((QSqlQuery*)this) = (const QSqlQuery&)query; [1]// QSqlQuery::operator=( (const QSqlQuery &)query ); [2] return *this;}
../smartQuery/src/smartQuery.cpp: In copy constructor ‘smartQuery::smartQuery(const smartQuery&)’:../smartQuery/src/smartQuery.cpp:23: предупреждение: base class ‘class QSqlQuery’ should be explicitly initialized in the copy constructor
29 qDebug() << QObject::tr("Конструктор без параметров");30 smartQuery sq;31 smartQuery sq3;32 33 qDebug() << QObject::tr("Конструктор присваивания");34 smartQuery sq2 = sq;35 36 qDebug() << QObject::tr("Операция присваивания");37 sq3 = sq2;38 39 sq3.addKey("k");40 sq3.addKey("value");41 sq3.select("org");
"Конструктор без параметров" "Конструктор присваивания" "Операция присваивания" "знач 1""знач 2""знач 3"...
24 smartQuery sq2 = sq; 25 26 sq2.addKey("password"); 27 sq2.addKey("fullname"); 28 sq2.addKey("uid"); 29 sq2.addKey("gid"); 30 sq2.addKey("orgid"); 31 sq2.addKey("orgsecid"); 32 sq2.select(_tblUsers, "login", leLogin->text());