2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "DatabaseEnv.h"
23 QueryResultSqlite::QueryResultSqlite(char **tableData
, uint32 rowCount
, uint32 fieldCount
) :
24 QueryResult(rowCount
, fieldCount
), mTableData(tableData
), mTableIndex(0)
26 mCurrentRow
= new Field
[mFieldCount
];
28 for (uint32 i
= 0; i
< mFieldCount
; i
++)
30 mFieldNames
[i
] = mTableData
[i
];
31 mCurrentRow
[i
].SetType(Field::DB_TYPE_UNKNOWN
);
35 QueryResultSqlite::~QueryResultSqlite()
40 bool QueryResultSqlite::NextRow()
48 if (mTableIndex
>= mRowCount
)
54 startIndex
= (mTableIndex
+ 1) * mFieldCount
;
55 for (i
= 0; i
< mFieldCount
; i
++)
57 mCurrentRow
[i
].SetValue(mTableData
[startIndex
+ i
]);
64 void QueryResultSqlite::EndQuery()
68 delete [] mCurrentRow
;
73 sqlite_free_table(mTableData
);
78 enum Field::DataTypes
QueryResultSqlite::ConvertNativeType(const char* sqliteType
) const
85 return Field::DB_TYPE_STRING
;
87 return Field::DB_TYPE_INTEGER
;
89 return Field::DB_TYPE_FLOAT
;
91 return Field::DB_TYPE_UNKNOWN
;
94 return Field::DB_TYPE_UNKNOWN
;