Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update to Mysql V3
  • Loading branch information
Gannon001 committed Apr 1, 2019
1 parent 8b01760 commit bcbb08a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions resources/gcphone/server/app_tchat.lua
Expand Up @@ -6,13 +6,15 @@ end

function TchatAddMessage (channel, message)
local Query = "INSERT INTO phone_app_chat (`channel`, `message`) VALUES(@channel, @message);"
local Query2 = 'SELECT * from phone_app_chat WHERE `id` = (SELECT LAST_INSERT_ID());'
local Query2 = 'SELECT * from phone_app_chat WHERE `id` = @id;'
local Parameters = {
['@channel'] = channel,
['@message'] = message
}
MySQL.Async.fetchAll(Query .. Query2, Parameters, function (reponse)
TriggerClientEvent('gcPhone:tchat_receive', -1, reponse[1])
MySQL.Async.insert(Query, Parameters, function (id)
MySQL.Async.fetchAll(Query2, { ['@id'] = id }, function (reponse)
TriggerClientEvent('gcPhone:tchat_receive', -1, reponse[1])
end)
end)
end

Expand Down
7 changes: 5 additions & 2 deletions resources/gcphone/server/server.lua
Expand Up @@ -172,15 +172,18 @@ end)

function _internalAddMessage(transmitter, receiver, message, owner)
local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner);"
local Query2 = 'SELECT * from phone_messages WHERE `id` = (SELECT LAST_INSERT_ID());'
local Query2 = 'SELECT * from phone_messages WHERE `id` = @id;'
local Parameters = {
['@transmitter'] = transmitter,
['@receiver'] = receiver,
['@message'] = message,
['@isRead'] = owner,
['@owner'] = owner
}
return MySQL.Sync.fetchAll(Query .. Query2, Parameters)[1]
local id = MySQL.Sync.insert(Query, Parameters)
return MySQL.Sync.fetchAll(Query2, {
['@id'] = id
})
end

function addMessage(source, identifier, phone_number, message)
Expand Down

0 comments on commit bcbb08a

Please sign in to comment.