mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-01-12 14:30:11 +01:00
folder_email fix
Change-Id: I1c2e7aa68d06b6873e38ae13fef868aa7eb80413 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
8b0995a556
commit
f4c656b0ae
@ -110,6 +110,7 @@
|
||||
#define SQL_PREPARED_STMT_GET_FOLDER_UID_BY_EMAIL "SELECT `uid` FROM " SQL_FOLDER_EMAIL_TABLE " WHERE `email`=?"
|
||||
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)"
|
||||
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EXTRA_TABLE "INSERT INTO `" SQL_FOLDER_EXTRA_TABLE "` (`name`, `uid`) VALUES(?,?)"
|
||||
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EMAIL_TABLE "INSERT INTO `" SQL_FOLDER_EMAIL_TABLE "` (`email`) VALUES(?)"
|
||||
#define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND reference=''"
|
||||
#define SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS "SELECT id, type, username, password, server FROM " SQL_IMPORT_TABLE " WHERE started=0 ORDER BY id LIMIT 0,1"
|
||||
#define SQL_PREPARED_STMT_INSERT_FOLDER_MESSAGE "INSERT INTO " SQL_FOLDER_MESSAGE_TABLE " (`folder_id`, `message_id`, `uid`) VALUES(?,?,?)"
|
||||
|
20
src/folder.c
20
src/folder.c
@ -18,6 +18,21 @@
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
void insert_email_to_table(struct session_data *sdata, struct __data *data){
|
||||
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EMAIL_TABLE) == ERR) return;
|
||||
|
||||
p_bind_init(data);
|
||||
|
||||
data->sql[data->pos] = data->import->email; data->type[data->pos] = TYPE_STRING; data->pos++;
|
||||
|
||||
if(p_exec_query(sdata, data->stmt_insert_into_folder_table, data) == OK){
|
||||
data->import->uid = p_get_insert_id(data->stmt_insert_into_folder_table);
|
||||
}
|
||||
|
||||
close_prepared_statement(data->stmt_insert_into_folder_table);
|
||||
}
|
||||
|
||||
|
||||
void get_folder_uid_by_email(struct session_data *sdata, struct __data *data){
|
||||
int uid = 0;
|
||||
|
||||
@ -37,11 +52,10 @@ void get_folder_uid_by_email(struct session_data *sdata, struct __data *data){
|
||||
p_free_results(data->stmt_get_folder_id);
|
||||
}
|
||||
|
||||
printf("uid=%d\n", uid);
|
||||
|
||||
close_prepared_statement(data->stmt_get_folder_id);
|
||||
|
||||
data->import->uid = uid;
|
||||
if(uid > 0) data->import->uid = uid;
|
||||
else insert_email_to_table(sdata, data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,7 +282,7 @@ create table if not exists `folder` (
|
||||
create table if not exists `folder_email` (
|
||||
`uid` int unsigned not null auto_increment,
|
||||
`email` char(128) not null unique,
|
||||
key `folder_user_idx` (`uid`)
|
||||
key `folder_user_idx` (`uid`),
|
||||
key `folder_user_idx2` (`email`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user