![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on [Help]SQLite3 Function not working... @_@ within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I'm in desperate need of help... I can not figure out why this function will not work "sqlite3_get_table" Here is ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() Party at Las Noches!
|
I'm in desperate need of help... I can not figure out why this function will not work "sqlite3_get_table" Here is the Source Code and it compiles perfectly fine no errors though when I run it, it outputs nothing...
Main.c: Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <sqlite3.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("SQLite Sample", 0, 1, 0);
#define printf pspDebugScreenPrintf
static int callback(void *NotUsed, int argc, char **argv, char **azColName);
int main(int argc, char *argv[]) {
SceCtrlData pad;
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char **results = NULL;
int exit = 0;
int rows;
int i;
pspDebugScreenInit();
pspDebugScreenClear();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
sceDisplayWaitVblankStart();
pspDebugScreenSetXY(0, 0);
rc = sqlite3_open("./flashmod.db", &db);
if( rc ) {
printf("Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
}
else {
rc = sqlite3_get_table(db, "SELECT * FROM xmb", &results, &rows, NULL, &zErrMsg);
if( rc != SQLITE_OK ) {
printf("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
for(i = 1; i < rows; i++) {
printf(" %s: %s\n By %s", results[i], results[i+rows], results[i+rows*2]);
}
sqlite3_close(db);
}
printf("\nPress X to exit.");
while(exit == 0) {
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons != 0){
if (pad.Buttons & PSP_CTRL_CROSS){
exit = 1;
}
}
sceDisplayWaitVblankStart();
}
sceKernelExitGame();
return 0;
}
Code:
TARGET = sqlite OBJS = main.o INCDIR = CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LDFLAGS = LIBS = -lpspdebug -lpspsdk -lsqlite3 -lc EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = sqlite PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak Thanks in advance
__________________
|
|
|
|
|
|
#2 |
|
Looks to me like you are trying to display the results wrong. I didn't test this, but I think it's the issue here.
Documentation for sqlite3_get_table: Code:
int sqlite3_get_table( sqlite3*, /* An open database */ const char *sql, /* SQL to be executed */ char ***resultp, /* Result written to a char *[] that this points to */ int *nrow, /* Number of result rows written here */ int *ncolumn, /* Number of result columns written here */ char **errmsg /* Error msg written here */ ); void sqlite3_free_table(char **result); |
|
|
|
|
|
|
#3 | |
![]() ![]() Party at Las Noches!
|
This may help out alittle...
![]() Quote:
rc = sqlite3_get_table(db, "SELECT * FROM xmb", &results, &rows, NULL, &zErrMsg); It should equal the number of rows in the table XMB... I haven't checked to see if it does or not that may be a good thing to try I don't understand why this is not working
__________________
|
|
|
|
|
|
|
#4 |
![]() ![]() Party at Las Noches!
|
Bump... =/ Still can't figure it out...
__________________
|
|
|
|
|
|
#5 | |
![]() ![]() Party at Las Noches!
|
Quote:
__________________
|
|
|
|
|
|
|
#6 | |
![]() ![]() Enter Custom Title
|
Hi!
![]() Quote:
Code:
pspDebugScreenPrintf("\n");
sprintf(sql, "Select * from test_table order by column_1");
retValue = sqlite3_exec(db, sql, SQLiteCallback, 0, &zErr);
if (retValue != SQLITE_OK){
pspDebugScreenPrintf("\n");
pspDebugScreenPrintf("Error reading records: %s", zErr);
error++;
}else{
pspDebugScreenPrintf("OK");
}
Code:
int SQLiteCallback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc;i++){
pspDebugScreenPrintf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
pspDebugScreenPrintf("\n");
return(0);
}
Sakya
__________________
"And they're giving me a wonderful potion, 'Cos I cannot contain my emotion. And even though, I'm feeling good, Something tells me, I'd better activate my prayer capsule." Supper's Ready (Genesis) |
|
|
|
|
![]() |
| Tags |
| function , helpsqlite3 , working |
| Thread Tools | |
|
|