mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
correct wrong var name
This commit is contained in:
parent
a64e53bb59
commit
a9d93035b6
2 changed files with 7 additions and 7 deletions
|
|
@ -171,7 +171,7 @@ QVariant QT::iniDb(const QVariant& vName) {
|
||||||
return vName;
|
return vName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QT::sqlQuery(const QVariant& vQuery, const QVariant& vValues, const QVariant& vRows) {
|
QVariant QT::sqlQuery(const QVariant& vQuery, const QVariant& vValues, const QVariant& vCols) {
|
||||||
QVariantList results;
|
QVariantList results;
|
||||||
QSqlQuery sqlQuery(db);
|
QSqlQuery sqlQuery(db);
|
||||||
if (db.open()) {
|
if (db.open()) {
|
||||||
|
|
@ -182,11 +182,11 @@ QVariant QT::sqlQuery(const QVariant& vQuery, const QVariant& vValues, const QVa
|
||||||
sqlQuery.addBindValue(value);
|
sqlQuery.addBindValue(value);
|
||||||
}
|
}
|
||||||
if (sqlQuery.exec()) {
|
if (sqlQuery.exec()) {
|
||||||
auto rows = vRows.toInt();
|
auto cols = vCols.toInt();
|
||||||
while (sqlQuery.next()) {
|
while (sqlQuery.next()) {
|
||||||
if (rows > 1) {
|
if (cols > 1) {
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
for (auto r = 0; r < rows; r++) {
|
for (auto r = 0; r < cols; r++) {
|
||||||
list << sqlQuery.value(r);
|
list << sqlQuery.value(r);
|
||||||
}
|
}
|
||||||
results << QVariant(list);
|
results << QVariant(list);
|
||||||
|
|
@ -194,7 +194,7 @@ QVariant QT::sqlQuery(const QVariant& vQuery, const QVariant& vValues, const QVa
|
||||||
results << sqlQuery.value(0);
|
results << sqlQuery.value(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!rows && query.startsWith("insert", Qt::CaseInsensitive)) {
|
if (!cols && query.startsWith("insert", Qt::CaseInsensitive)) {
|
||||||
results << sqlQuery.lastInsertId();
|
results << sqlQuery.lastInsertId();
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
(defvar *file* nil)
|
(defvar *file* nil)
|
||||||
|
|
||||||
(defun query (query &rest values)
|
(defun query (query &rest values)
|
||||||
(let ((rows (and (x:starts-with "select" query)
|
(let ((cols (and (x:starts-with "select" query)
|
||||||
(1+ (count #\, (subseq query 0 (search "from" query)))))))
|
(1+ (count #\, (subseq query 0 (search "from" query)))))))
|
||||||
(qrun* (qt:sql-query qt:*cpp* query values rows))))
|
(qrun* (qt:sql-query qt:*cpp* query values cols))))
|
||||||
|
|
||||||
(defun ini ()
|
(defun ini ()
|
||||||
(setf *file* (app:in-data-path "db"))
|
(setf *file* (app:in-data-path "db"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue