Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krmaet
/
Lennubroneerimis_tarkvara
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7baa091f
authored
2 years ago
by
karade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update generator.c
parent
b34d0175
Inimeste_generaator
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
generator.c
generator.c
View file @
7baa091f
...
...
@@ -151,7 +151,7 @@ void PrintTable(MYSQL_RES *result)
void
insertPersonIntoTable
(
MYSQL
*
con
,
users
data
)
{
char
query
[
1024
];
char
query
[
1024
];
//salvestan mysql päringu stringi
sprintf
(
query
,
"INSERT INTO users (documentNum, firstName, "
"lastName, dateOfBirth, email, residency, checkedIn, seat,"
...
...
@@ -162,10 +162,40 @@ void insertPersonIntoTable(MYSQL* con, users data)
printf
(
"DEBUG:%s
\n\n
"
,
query
);
if
(
mysql_query
(
con
,
query
))
{
if
(
mysql_query
(
con
,
query
))
{
//päring serverile
printf
(
"Error inserting Users into MySQL table: %s
\n
"
,
mysql_error
(
con
));
exit
(
EXIT_FAILURE
);
}
char
bookingCode
[
9
];
const
char
letters
[]
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
//broneeringunumbri genereerimine
{
bookingCode
[
i
]
=
letters
[
GetRand
(
0
,
35
)];
}
bookingCode
[
8
]
=
'\0'
;
//päring et saada kätte viimane sisestatud väljale loodud ID
if
(
mysql_query
(
con
,
"SELECT last_insert_id();"
))
{
finish_with_error
(
con
);
}
MYSQL_RES
*
result
=
mysql_store_result
(
con
);
MYSQL_ROW
row
;
row
=
mysql_fetch_row
(
result
);
int
res
=
atoi
(
row
[
0
]);
sprintf
(
query
,
"INSERT INTO bookings (bookingNumber, flight_id, user_id)"
"VALUES ('%s', %d, %d);"
,
bookingCode
,
data
.
flight_id
,
res
);
if
(
mysql_query
(
con
,
query
))
{
printf
(
"Error creating bookings for the users: %s
\n
"
,
mysql_error
(
con
));
exit
(
EXIT_FAILURE
);
}
}
MYSQL
*
connectToMySQLServer
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment